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/licenses/check-disk-name.ts
Views: 687
1
/* Return information about a given license. */
2
3
import getPool from "@cocalc/database/pool";
4
import { checkDedicateDiskNameUniqueness } from "@cocalc/util/licenses/check-disk-name-uniqueness";
5
import getAccountId from "lib/account/get-account";
6
import getParams from "lib/api/get-params";
7
8
export default async function handle(req, res) {
9
try {
10
res.json(await get(req));
11
} catch (err) {
12
res.json({ error: err.message });
13
return;
14
}
15
}
16
17
async function get(req): Promise<{ available: boolean }> {
18
const account_id = await getAccountId(req);
19
if (account_id == null) throw new Error(`user not logged in`);
20
return await checkDedicateDiskNameUniqueness(getPool(), getParams(req).name);
21
}
22
23