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/api-keys.ts
Views: 687
1
/*
2
v2 API endpoint for managing your api keys
3
*/
4
5
import getAccountId from "lib/account/get-account";
6
import manageApiKeys from "@cocalc/server/api/manage";
7
import getParams from "lib/api/get-params";
8
9
export default async function handle(req, res) {
10
try {
11
const account_id = await getAccountId(req);
12
if (!account_id) {
13
throw Error("must be signed in");
14
}
15
const { action, project_id, name, expire, id } = getParams(req);
16
const response = await manageApiKeys({
17
account_id,
18
action,
19
project_id,
20
name,
21
expire,
22
id,
23
});
24
res.json({ response });
25
} catch (err) {
26
res.json({ error: err.message });
27
}
28
}
29
30