diff options
Diffstat (limited to 'apps/web/app/api/v1/lists')
| -rw-r--r-- | apps/web/app/api/v1/lists/[listId]/route.ts | 33 | ||||
| -rw-r--r-- | apps/web/app/api/v1/lists/route.ts | 14 |
2 files changed, 47 insertions, 0 deletions
diff --git a/apps/web/app/api/v1/lists/[listId]/route.ts b/apps/web/app/api/v1/lists/[listId]/route.ts new file mode 100644 index 00000000..205a779f --- /dev/null +++ b/apps/web/app/api/v1/lists/[listId]/route.ts @@ -0,0 +1,33 @@ +import { NextRequest } from "next/server"; +import { buildHandler } from "@/app/api/v1/utils/handler"; +import { adaptPagination, zPagination } from "@/app/api/v1/utils/pagination"; + +export const dynamic = "force-dynamic"; + +export const GET = ( + req: NextRequest, + { params }: { params: { listId: string } }, +) => + buildHandler({ + req, + searchParamsSchema: zPagination, + handler: async ({ api, searchParams }) => { + const [list, bookmarks] = await Promise.all([ + api.lists.get({ + listId: params.listId, + }), + api.bookmarks.getBookmarks({ + listId: params.listId, + limit: searchParams.limit, + cursor: searchParams.cursor, + }), + ]); + return { + status: 200, + resp: { + ...list, + ...adaptPagination(bookmarks), + }, + }; + }, + }); diff --git a/apps/web/app/api/v1/lists/route.ts b/apps/web/app/api/v1/lists/route.ts new file mode 100644 index 00000000..f2816219 --- /dev/null +++ b/apps/web/app/api/v1/lists/route.ts @@ -0,0 +1,14 @@ +import { NextRequest } from "next/server"; + +import { buildHandler } from "../utils/handler"; + +export const dynamic = "force-dynamic"; + +export const GET = (req: NextRequest) => + buildHandler({ + req, + handler: async ({ api }) => { + const lists = await api.lists.list(); + return { status: 200, resp: lists }; + }, + }); |
