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/accounts/get-names.ts
Views: 687
1
/*
2
Get first and last name for a list of account_id's.
3
4
The output is an object {names:{[account_id]:{first_name:string;last_name:string}}},
5
where the value for a given account_id is not given if that account does not
6
exist or was deleted (instead of an error).
7
8
There is about 30s of caching if you call this with the same input twice.
9
*/
10
11
import getAccountId from "lib/account/get-account";
12
import getParams from "lib/api/get-params";
13
import { getNames } from "@cocalc/server/accounts/get-name";
14
15
export default async function handle(req, res) {
16
const account_id = await getAccountId(req);
17
if (account_id == null) {
18
res.json({ error: "must be signed in" });
19
return;
20
}
21
22
let { account_ids } = getParams(req);
23
24
try {
25
const names = await getNames(account_ids);
26
res.json({ names });
27
} catch (err) {
28
res.json({ error: `${err.message}` });
29
}
30
}
31
32