MCPcopy Create free account
hub / github.com/code100x/cms / createBookmarkHandler

Function createBookmarkHandler

src/actions/bookmark/index.ts:18–42  ·  view source on GitHub ↗
(
  data: InputTypeCreateBookmark,
)

Source from the content-addressed store, hash-verified

16};
17
18const createBookmarkHandler = async (
19 data: InputTypeCreateBookmark,
20): Promise<ReturnTypeCreateBookmark> => {
21 const session = await getServerSession(authOptions);
22
23 if (!session || !session.user) {
24 return { error: 'Unauthorized or insufficient permissions' };
25 }
26
27 const { contentId } = data;
28 const userId = session.user.id;
29
30 try {
31 const addedBookmark = await db.bookmark.create({
32 data: {
33 contentId,
34 userId,
35 },
36 });
37 reloadBookmarkPage();
38 return { data: addedBookmark };
39 } catch (error: any) {
40 return { error: error.message || 'Failed to create comment.' };
41 }
42};
43
44const deleteBookmarkHandler = async (
45 data: InputTypeDeleteBookmark,

Callers

nothing calls this directly

Calls 1

reloadBookmarkPageFunction · 0.85

Tested by

no test coverage detected