"use strict";
/*
Get shopping cart for signed in user.  Can also optionally get everything
ever removed from cart, and also everything ever purchased.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const checkout_1 = __importDefault(require("@cocalc/server/shopping/cart/checkout"));
const get_account_1 = __importDefault(require("lib/account/get-account"));
const recaptcha_1 = __importDefault(require("@cocalc/server/auth/recaptcha"));
async function handle(req, res) {
    try {
        await doIt(req);
        res.json({ success: true });
    }
    catch (err) {
        res.json({ error: `${err.message}` });
        return;
    }
}
exports.default = handle;
async function doIt(req) {
    await (0, recaptcha_1.default)(req);
    const account_id = await (0, get_account_1.default)(req);
    if (account_id == null) {
        throw Error("must be signed in to check out");
    }
    return await (0, checkout_1.default)(account_id);
}
//# sourceMappingURL=checkout.js.map