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/vouchers/set-voucher-code-notes.ts
Views: 687
1
import setVoucherCodeNotes from "@cocalc/server/vouchers/set-voucher-code-notes";
2
import getAccountId from "lib/account/get-account";
3
import getParams from "lib/api/get-params";
4
5
export default async function handle(req, res) {
6
try {
7
const result = await doIt(req);
8
res.json({ ...result, success: true });
9
} catch (err) {
10
res.json({ error: `${err.message}` });
11
return;
12
}
13
}
14
15
async function doIt(req) {
16
const { code, notes } = getParams(req);
17
const account_id = await getAccountId(req);
18
if (account_id == null) {
19
throw Error("must be signed in");
20
}
21
return { codes: await setVoucherCodeNotes({ account_id, code, notes }) };
22
}
23
24