"use strict";
/* Request to save a particular public path. */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const save_1 = __importDefault(require("@cocalc/server/public-paths/save"));
const get_account_1 = __importDefault(require("lib/account/get-account"));
const get_params_1 = __importDefault(require("lib/api/get-params"));
async function handle(req, res) {
    try {
        const account_id = await (0, get_account_1.default)(req);
        if (account_id == null) {
            throw Error("must be signed in to save public path (have to be collab on project)");
        }
        const { id } = (0, get_params_1.default)(req);
        if (!id) {
            throw Error("must specify id of public path");
        }
        await (0, save_1.default)(id, account_id);
        res.json({});
    }
    catch (err) {
        res.json({ error: `${err.message}` });
        return;
    }
}
exports.default = handle;
//# sourceMappingURL=save.js.map