diff options
Diffstat (limited to 'apps/web/app/api/v1/bookmarks')
| -rw-r--r-- | apps/web/app/api/v1/bookmarks/route.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/apps/web/app/api/v1/bookmarks/route.ts b/apps/web/app/api/v1/bookmarks/route.ts new file mode 100644 index 00000000..0d58901d --- /dev/null +++ b/apps/web/app/api/v1/bookmarks/route.ts @@ -0,0 +1,25 @@ +import { NextRequest } from "next/server"; +import { z } from "zod"; + +import { buildHandler } from "../utils/handler"; +import { adaptPagination, zPagination } from "../utils/pagination"; +import { zStringBool } from "../utils/types"; + +export const dynamic = "force-dynamic"; + +export const GET = (req: NextRequest) => + buildHandler({ + req, + searchParamsSchema: z + .object({ + favourited: zStringBool.optional(), + archived: zStringBool.optional(), + }) + .and(zPagination), + handler: async ({ api, searchParams }) => { + const bookmarks = await api.bookmarks.getBookmarks({ + ...searchParams, + }); + return { status: 200, resp: adaptPagination(bookmarks) }; + }, + }); |
