"use strict";
/*
Get recent purchases.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const recent_purchases_1 = __importDefault(require("@cocalc/server/shopping/cart/recent-purchases"));
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 {
        res.json(await get(req));
    }
    catch (err) {
        res.json({ error: `${err.message}` });
        return;
    }
}
exports.default = handle;
async function get(req) {
    const account_id = await (0, get_account_1.default)(req);
    if (account_id == null) {
        throw Error("must be signed in to get shopping cart information");
    }
    // recent = postgresql time, e.g., "1 day".  Can be omitted, in which case default is "1 week".
    const { recent } = (0, get_params_1.default)(req);
    return await (0, recent_purchases_1.default)({ account_id, recent });
}
//# sourceMappingURL=recent-purchases.js.map