aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web')
-rw-r--r--apps/web/app/api/v1/bookmarks/[bookmarkId]/route.ts14
-rw-r--r--apps/web/app/api/v1/lists/[listId]/route.ts16
-rw-r--r--apps/web/app/api/v1/tags/[tagId]/route.ts16
-rw-r--r--apps/web/app/api/v1/utils/handler.ts4
4 files changed, 48 insertions, 2 deletions
diff --git a/apps/web/app/api/v1/bookmarks/[bookmarkId]/route.ts b/apps/web/app/api/v1/bookmarks/[bookmarkId]/route.ts
index af4c0792..0315ff8c 100644
--- a/apps/web/app/api/v1/bookmarks/[bookmarkId]/route.ts
+++ b/apps/web/app/api/v1/bookmarks/[bookmarkId]/route.ts
@@ -16,3 +16,17 @@ export const GET = (
return { status: 200, resp: bookmark };
},
});
+
+export const DELETE = (
+ req: NextRequest,
+ { params }: { params: { bookmarkId: string } },
+) =>
+ buildHandler({
+ req,
+ handler: async ({ api }) => {
+ await api.bookmarks.deleteBookmark({
+ bookmarkId: params.bookmarkId,
+ });
+ return { status: 204 };
+ },
+ });
diff --git a/apps/web/app/api/v1/lists/[listId]/route.ts b/apps/web/app/api/v1/lists/[listId]/route.ts
index 205a779f..d3e1f17c 100644
--- a/apps/web/app/api/v1/lists/[listId]/route.ts
+++ b/apps/web/app/api/v1/lists/[listId]/route.ts
@@ -31,3 +31,19 @@ export const GET = (
};
},
});
+
+export const DELETE = (
+ req: NextRequest,
+ { params }: { params: { listId: string } },
+) =>
+ buildHandler({
+ req,
+ handler: async ({ api }) => {
+ await api.lists.delete({
+ listId: params.listId,
+ });
+ return {
+ status: 204,
+ };
+ },
+ });
diff --git a/apps/web/app/api/v1/tags/[tagId]/route.ts b/apps/web/app/api/v1/tags/[tagId]/route.ts
index 9c9d15fd..a82e693c 100644
--- a/apps/web/app/api/v1/tags/[tagId]/route.ts
+++ b/apps/web/app/api/v1/tags/[tagId]/route.ts
@@ -31,3 +31,19 @@ export const GET = (
};
},
});
+
+export const DELETE = (
+ req: NextRequest,
+ { params }: { params: { tagId: string } },
+) =>
+ buildHandler({
+ req,
+ handler: async ({ api }) => {
+ await api.tags.delete({
+ tagId: params.tagId,
+ });
+ return {
+ status: 204,
+ };
+ },
+ });
diff --git a/apps/web/app/api/v1/utils/handler.ts b/apps/web/app/api/v1/utils/handler.ts
index d66bb299..d5f470df 100644
--- a/apps/web/app/api/v1/utils/handler.ts
+++ b/apps/web/app/api/v1/utils/handler.ts
@@ -81,7 +81,7 @@ export async function buildHandler<
bodySchema,
}: {
req: NextRequest;
- handler: (req: InputT) => Promise<{ status: number; resp: object }>;
+ handler: (req: InputT) => Promise<{ status: number; resp?: object }>;
searchParamsSchema?: SearchParamsT | undefined;
bodySchema?: BodyT | undefined;
}) {
@@ -108,7 +108,7 @@ export async function buildHandler<
body,
} as InputT);
- return new Response(JSON.stringify(resp), {
+ return new Response(resp ? JSON.stringify(resp) : null, {
status,
headers: {
"Content-Type": "application/json",