"use strict";
(() => {
var exports = {};
exports.id = 31;
exports.ids = [31];
exports.modules = {

/***/ 439491:
/***/ ((module) => {

module.exports = require("assert");

/***/ }),

/***/ 714300:
/***/ ((module) => {

module.exports = require("buffer");

/***/ }),

/***/ 706113:
/***/ ((module) => {

module.exports = require("crypto");

/***/ }),

/***/ 809523:
/***/ ((module) => {

module.exports = require("dns");

/***/ }),

/***/ 582361:
/***/ ((module) => {

module.exports = require("events");

/***/ }),

/***/ 657147:
/***/ ((module) => {

module.exports = require("fs");

/***/ }),

/***/ 241808:
/***/ ((module) => {

module.exports = require("net");

/***/ }),

/***/ 371017:
/***/ ((module) => {

module.exports = require("path");

/***/ }),

/***/ 12781:
/***/ ((module) => {

module.exports = require("stream");

/***/ }),

/***/ 371576:
/***/ ((module) => {

module.exports = require("string_decoder");

/***/ }),

/***/ 924404:
/***/ ((module) => {

module.exports = require("tls");

/***/ }),

/***/ 257310:
/***/ ((module) => {

module.exports = require("url");

/***/ }),

/***/ 473837:
/***/ ((module) => {

module.exports = require("util");

/***/ }),

/***/ 426628:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);

// EXPORTS
__webpack_require__.d(__webpack_exports__, {
  "default": () => (/* binding */ handler)
});

// EXTERNAL MODULE: external "path"
var external_path_ = __webpack_require__(371017);
// EXTERNAL MODULE: ../util/dist/misc.js
var misc = __webpack_require__(854006);
;// CONCATENATED MODULE: ./lib/share/util.ts
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ 

function isUUID(s) {
    // todo: add full check.
    return typeof s == "string" && s.length == 36;
}
function isSha1Hash(s) {
    return typeof s == "string" && s.length == 40;
// todo: could add full check (i.e., each character is in 0-e)
}
function trunc(s, n) {
    return s.length > n ? s.slice(0, n - 1) + "\u2026" : s;
}
function getTitle({ path , relativePath  }) {
    const b = basename(relativePath);
    return b ? b : basename(path);
}

// EXTERNAL MODULE: ../database/dist/pool/index.js
var dist_pool = __webpack_require__(541808);
var pool_default = /*#__PURE__*/__webpack_require__.n(dist_pool);
;// CONCATENATED MODULE: ./pages/api/share/public_paths/counter/[id].ts
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */ /*
API to increment the counter for a public_path.

This is of course really dumb and naive and somebody could trivially mess this up.
I'm just implementing this to get the same functionality as before and maybe better
inform server side rendering.  We'll do something much better later.
*/ 

async function handler(req, res) {
    const { id  } = req.query;
    if (!isSha1Hash(id)) {
        res.error("id must be a sha1 hash");
        return;
    }
    const pool = pool_default()();
    await pool.query("UPDATE public_paths SET counter = coalesce(counter,0) + 1 WHERE id=$1", [
        id
    ]);
    res.end();
};


/***/ })

};
;

// load runtime
var __webpack_require__ = require("../../../../../webpack-api-runtime.js");
__webpack_require__.C(exports);
var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
var __webpack_exports__ = __webpack_require__.X(0, [1970,2921,1808,9738], () => (__webpack_exec__(426628)));
module.exports = __webpack_exports__;

})();