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-log.ts
Views: 687
1
/*
2
Get event log for a particular compute server.
3
*/
4
5
import getAccountId from "lib/account/get-account";
6
import { getEventLog } from "@cocalc/server/compute/event-log";
7
import getParams from "lib/api/get-params";
8
9
import { apiRoute, apiRouteOperation } from "lib/api";
10
import {
11
GetComputeServerLogInputSchema,
12
GetComputeServerLogOutputSchema,
13
} from "lib/api/schema/compute/get-log";
14
15
async function handle(req, res) {
16
try {
17
res.json(await get(req));
18
} catch (err) {
19
res.json({ error: `${err.message}` });
20
return;
21
}
22
}
23
24
async function get(req) {
25
const account_id = await getAccountId(req);
26
if (!account_id) {
27
throw Error("must be signed in");
28
}
29
const { id } = getParams(req);
30
return await getEventLog({ id, account_id });
31
}
32
33
export default apiRoute({
34
getLog: apiRouteOperation({
35
method: "POST",
36
openApiOperation: {
37
tags: ["Compute"],
38
},
39
})
40
.input({
41
contentType: "application/json",
42
body: GetComputeServerLogInputSchema,
43
})
44
.outputs([
45
{
46
status: 200,
47
contentType: "application/json",
48
body: GetComputeServerLogOutputSchema,
49
},
50
])
51
.handler(handle),
52
});
53
54