CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/pages/api/v2/purchases/get-charges-by-service.ts
Views: 687
1
import getAccountId from "lib/account/get-account";
2
import { getChargesThisMonthByService } from "@cocalc/server/purchases/get-charges";
3
4
export default async function handle(req, res) {
5
try {
6
res.json(await get(req));
7
} catch (err) {
8
res.json({ error: `${err.message}` });
9
return;
10
}
11
}
12
13
async function get(req) {
14
const account_id = await getAccountId(req);
15
if (account_id == null) {
16
throw Error("must be signed in");
17
}
18
return await getChargesThisMonthByService(account_id);
19
}
20
21