diff options
Diffstat (limited to 'web/lib')
| -rw-r--r-- | web/lib/api.ts | 10 | ||||
| -rw-r--r-- | web/lib/services/links.ts | 9 |
2 files changed, 17 insertions, 2 deletions
diff --git a/web/lib/api.ts b/web/lib/api.ts index 193d9bb7..12ce9464 100644 --- a/web/lib/api.ts +++ b/web/lib/api.ts @@ -35,8 +35,8 @@ async function doRequest<T>( opts?: RequestInit, ): Promise< | (InputSchema<T> extends ZodTypeAny - ? [z.infer<InputSchema<T>>, undefined] - : [undefined, undefined]) + ? [z.infer<InputSchema<T>>, undefined] + : [undefined, undefined]) | [undefined, FetchError] > { try { @@ -84,4 +84,10 @@ export default class APIClient { body: JSON.stringify(body), }); } + + static async unbookmarkLink(linkId: string) { + return await doRequest(`/links/${linkId}`, undefined, { + method: "DELETE", + }); + } } diff --git a/web/lib/services/links.ts b/web/lib/services/links.ts index f3ff1757..dbcbe9c4 100644 --- a/web/lib/services/links.ts +++ b/web/lib/services/links.ts @@ -1,6 +1,15 @@ import { LinkCrawlerQueue } from "@remember/shared/queues"; import prisma from "@remember/db"; +export async function unbookmarkLink(linkId: string, userId: string) { + await prisma.bookmarkedLink.delete({ + where: { + id: linkId, + userId, + }, + }); +} + export async function bookmarkLink(url: string, userId: string) { const link = await prisma.bookmarkedLink.create({ data: { |
