diff options
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) |
