diff options
| author | MohamedBassem <me@mbassem.com> | 2024-02-22 17:33:12 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-02-22 17:34:37 +0000 |
| commit | 2ac3c39a9c80305bb959d88561e78f65a1cd1be1 (patch) | |
| tree | abdf860a648d691377914702f4d5c804e02fd341 /packages/web/server/api | |
| parent | 61a1b2f40cf69d8c2055becf9119881cafa9da81 (diff) | |
| download | karakeep-2ac3c39a9c80305bb959d88561e78f65a1cd1be1.tar.zst | |
feature: Adding some loading card while the link is getting crawled
Diffstat (limited to '')
| -rw-r--r-- | packages/web/server/api/routers/bookmarks.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/packages/web/server/api/routers/bookmarks.ts b/packages/web/server/api/routers/bookmarks.ts index 37d12eb9..65f20ef5 100644 --- a/packages/web/server/api/routers/bookmarks.ts +++ b/packages/web/server/api/routers/bookmarks.ts @@ -26,6 +26,7 @@ const defaultBookmarkFields = { description: true, imageUrl: true, favicon: true, + crawledAt: true, }, }, tags: { @@ -153,6 +154,30 @@ export const bookmarksAppRouter = router({ bookmarkId: input.bookmarkId, }); }), + getBookmark: authedProcedure + .input( + z.object({ + id: z.string(), + }), + ) + .output(zBookmarkSchema) + .query(async ({ input, ctx }) => { + const bookmark = await prisma.bookmark.findUnique({ + where: { + userId: ctx.user.id, + id: input.id, + }, + select: defaultBookmarkFields, + }); + if (!bookmark) { + throw new TRPCError({ + code: "NOT_FOUND", + message: "Bookmark not found", + }); + } + + return toZodSchema(bookmark); + }), getBookmarks: authedProcedure .input(zGetBookmarksRequestSchema) .output(zGetBookmarksResponseSchema) |
