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/compute/get-templates.ts
Views: 687
1
/*
2
Get Templates
3
*/
4
5
import { getTemplates } from "@cocalc/server/compute/templates";
6
7
import { apiRoute, apiRouteOperation } from "lib/api";
8
import { GetComputeServerTemplatesOutputSchema } from "lib/api/schema/compute/get-templates";
9
10
async function handle(_req, res) {
11
try {
12
res.json(await await getTemplates());
13
} catch (err) {
14
res.json({ error: `${err.message}` });
15
return;
16
}
17
}
18
19
export default apiRoute({
20
getTemplates: apiRouteOperation({
21
method: "POST",
22
openApiOperation: {
23
tags: ["Compute"],
24
},
25
})
26
.outputs([
27
{
28
status: 200,
29
contentType: "application/json",
30
body: GetComputeServerTemplatesOutputSchema,
31
},
32
])
33
.handler(handle),
34
});
35
36