"use strict";
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/*
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.
*/
const util_1 = require("lib/share/util");
const pool_1 = __importDefault(require("@cocalc/database/pool"));
async function handler(req, res) {
    const { id } = req.query;
    if (!(0, util_1.isSha1Hash)(id)) {
        res.error("id must be a sha1 hash");
        return;
    }
    const pool = (0, pool_1.default)();
    await pool.query("UPDATE public_paths SET counter = coalesce(counter,0) + 1 WHERE id=$1", [id]);
    res.end();
}
exports.default = handler;
//# sourceMappingURL=%5Bid%5D.js.map