From 10dcf2e7429601fcbde42e3d10c46c074dc9a28a Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 20 Oct 2024 14:58:16 +0000 Subject: feature: Add APIs to create new lists and bookmarks --- apps/web/app/api/v1/lists/route.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'apps/web/app/api/v1/lists') 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 }; + }, + }); -- cgit v1.2.3-70-g09d2