"use strict";
/*
User query endpoint.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const user_query_1 = __importDefault(require("@cocalc/database/user-query"));
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) {
    const account_id = await (0, get_account_1.default)(req);
    // account_id = undefined <--> anonymous queries, which do exist.
    const { query } = (0, get_params_1.default)(req);
    try {
        const result = await (0, user_query_1.default)({ account_id, query });
        res.json({ query: result });
    }
    catch (err) {
        res.json({ error: `${err.message ? err.message : err}` });
    }
}
exports.default = handle;
//# sourceMappingURL=user-query.js.map