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-closing-dates.ts
Views: 687
1
/*
2
Return the last and next closing dates for this user.
3
*/
4
5
import getAccountId from "lib/account/get-account";
6
import {
7
getLastClosingDate,
8
getNextClosingDate,
9
} from "@cocalc/server/purchases/closing-date";
10
11
export default async function handle(req, res) {
12
try {
13
res.json(await get(req));
14
} catch (err) {
15
res.json({ error: `${err.message}` });
16
return;
17
}
18
}
19
20
async function get(req) {
21
const account_id = await getAccountId(req);
22
if (account_id == null) {
23
throw Error("must be signed in");
24
}
25
return {
26
last: await getLastClosingDate(account_id),
27
next: await getNextClosingDate(account_id),
28
};
29
}
30
31