Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/pages/api/v2/bookmarks/get.ts
5844 views
1
/*
2
* This file is part of CoCalc: Copyright © 2024 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
// NOOP endpoint - bookmarks now handled by conat
7
// Keeping endpoint for backwards compatibility with older clients
8
9
import { Request } from "express";
10
11
import { STARRED_FILES } from "@cocalc/util/consts/bookmarks";
12
13
async function handle(req, res) {
14
try {
15
res.json(await get(req));
16
} catch (err) {
17
res.json({ error: `${err.message}` });
18
return;
19
}
20
}
21
22
async function get(
23
req: Request,
24
): Promise<{
25
status: "success" | "error";
26
stars?: string[];
27
type?: string;
28
project_id?: string;
29
error?: string;
30
}> {
31
const { type, project_id } = req.body;
32
33
// NOOP: Always return empty bookmarks since they're now handled by conat
34
switch (type) {
35
case STARRED_FILES: {
36
return {
37
type,
38
project_id,
39
stars: [],
40
status: "success",
41
};
42
}
43
44
default:
45
return {
46
type,
47
project_id,
48
status: "error",
49
error: `cannot handle type '${type}'`,
50
};
51
}
52
}
53
54
export default handle;
55
56