Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/pages/api/v2/bookmarks/remove.ts
Views: 687
/*1* This file is part of CoCalc: Copyright © 2024 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Request } from "express";67import { getLogger } from "@cocalc/backend/logger";8import { saveStarredFilesBookmarks } from "@cocalc/server/bookmarks/starred";9import { STARRED_FILES } from "@cocalc/util/consts/bookmarks";10import { apiRoute, apiRouteOperation } from "lib/api";11import { processSetRequest } from "lib/api/bookmarks";12import {13BookmarkRemoveInputSchema,14BookmarkRemoveOutputSchema,15BookmarkSetOutputType,16} from "lib/api/schema/bookmarks";1718const L = getLogger("api:v2:bookmark:remove");1920async function handle(req, res) {21try {22res.json(await remove(req));23} catch (err) {24res.json({ error: `${err.message}` });25return;26}27}2829async function remove(req: Request): Promise<BookmarkSetOutputType> {30const { project_id, account_id, type, stars } = await processSetRequest(req);3132switch (type) {33case STARRED_FILES: {34L.debug("set", { project_id, stars });35await saveStarredFilesBookmarks({36project_id,37account_id,38stars,39mode: "remove",40});4142return { status: "success", project_id, type };43}4445default:46return { status: "error", error: `cannot handle type '${type}'` };47}48}4950export default apiRoute({51removeBookmarks: apiRouteOperation({52method: "POST",53openApiOperation: {54tags: ["Projects"],55},56})57.input({58contentType: "application/json",59body: BookmarkRemoveInputSchema,60})61.outputs([62{63status: 200,64contentType: "application/json",65body: BookmarkRemoveOutputSchema,66},67])68.handler(handle),69});707172