diff options
Diffstat (limited to 'apps/web/app')
| -rw-r--r-- | apps/web/app/api/v1/bookmarks/route.ts | 12 | ||||
| -rw-r--r-- | apps/web/app/api/v1/lists/route.ts | 12 |
2 files changed, 24 insertions, 0 deletions
diff --git a/apps/web/app/api/v1/bookmarks/route.ts b/apps/web/app/api/v1/bookmarks/route.ts index 0d58901d..1342f070 100644 --- a/apps/web/app/api/v1/bookmarks/route.ts +++ b/apps/web/app/api/v1/bookmarks/route.ts @@ -1,6 +1,8 @@ import { NextRequest } from "next/server"; import { z } from "zod"; +import { zNewBookmarkRequestSchema } from "@hoarder/shared/types/bookmarks"; + import { buildHandler } from "../utils/handler"; import { adaptPagination, zPagination } from "../utils/pagination"; import { zStringBool } from "../utils/types"; @@ -23,3 +25,13 @@ export const GET = (req: NextRequest) => return { status: 200, resp: adaptPagination(bookmarks) }; }, }); + +export const POST = (req: NextRequest) => + buildHandler({ + req, + bodySchema: zNewBookmarkRequestSchema, + handler: async ({ api, body }) => { + const bookmark = await api.bookmarks.createBookmark(body!); + return { status: 201, resp: bookmark }; + }, + }); diff --git a/apps/web/app/api/v1/lists/route.ts b/apps/web/app/api/v1/lists/route.ts index f2816219..724fadf2 100644 --- a/apps/web/app/api/v1/lists/route.ts +++ b/apps/web/app/api/v1/lists/route.ts @@ -1,5 +1,7 @@ import { NextRequest } from "next/server"; +import { zNewBookmarkListSchema } from "@hoarder/shared/types/lists"; + import { buildHandler } from "../utils/handler"; export const dynamic = "force-dynamic"; @@ -12,3 +14,13 @@ export const GET = (req: NextRequest) => return { status: 200, resp: lists }; }, }); + +export const POST = (req: NextRequest) => + buildHandler({ + req, + bodySchema: zNewBookmarkListSchema, + handler: async ({ api, body }) => { + const list = await api.lists.create(body!); + return { status: 201, resp: list }; + }, + }); |
