aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/app
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/app')
-rw-r--r--apps/web/app/api/v1/bookmarks/[bookmarkId]/route.ts18
-rw-r--r--apps/web/app/api/v1/lists/[listId]/route.ts18
-rw-r--r--apps/web/app/api/v1/tags/[tagId]/route.ts18
3 files changed, 54 insertions, 0 deletions
diff --git a/apps/web/app/api/v1/bookmarks/[bookmarkId]/route.ts b/apps/web/app/api/v1/bookmarks/[bookmarkId]/route.ts
index 0315ff8c..8fe4d9fe 100644
--- a/apps/web/app/api/v1/bookmarks/[bookmarkId]/route.ts
+++ b/apps/web/app/api/v1/bookmarks/[bookmarkId]/route.ts
@@ -1,6 +1,8 @@
import { NextRequest } from "next/server";
import { buildHandler } from "@/app/api/v1/utils/handler";
+import { zUpdateBookmarksRequestSchema } from "@hoarder/shared/types/bookmarks";
+
export const dynamic = "force-dynamic";
export const GET = (
@@ -17,6 +19,22 @@ export const GET = (
},
});
+export const PATCH = (
+ req: NextRequest,
+ { params }: { params: { bookmarkId: string } },
+) =>
+ buildHandler({
+ req,
+ bodySchema: zUpdateBookmarksRequestSchema.omit({ bookmarkId: true }),
+ handler: async ({ api, body }) => {
+ const bookmark = await api.bookmarks.updateBookmark({
+ bookmarkId: params.bookmarkId,
+ ...body!,
+ });
+ return { status: 200, resp: bookmark };
+ },
+ });
+
export const DELETE = (
req: NextRequest,
{ params }: { params: { bookmarkId: string } },
diff --git a/apps/web/app/api/v1/lists/[listId]/route.ts b/apps/web/app/api/v1/lists/[listId]/route.ts
index f5af286d..69c99fda 100644
--- a/apps/web/app/api/v1/lists/[listId]/route.ts
+++ b/apps/web/app/api/v1/lists/[listId]/route.ts
@@ -1,6 +1,8 @@
import { NextRequest } from "next/server";
import { buildHandler } from "@/app/api/v1/utils/handler";
+import { zNewBookmarkListSchema } from "@hoarder/shared/types/lists";
+
export const dynamic = "force-dynamic";
export const GET = (
@@ -20,6 +22,22 @@ export const GET = (
},
});
+export const PATCH = (
+ req: NextRequest,
+ { params }: { params: { listId: string } },
+) =>
+ buildHandler({
+ req,
+ bodySchema: zNewBookmarkListSchema.partial(),
+ handler: async ({ api, body }) => {
+ const list = await api.lists.edit({
+ listId: params.listId,
+ ...body!,
+ });
+ return { status: 200, resp: list };
+ },
+ });
+
export const DELETE = (
req: NextRequest,
{ params }: { params: { listId: string } },
diff --git a/apps/web/app/api/v1/tags/[tagId]/route.ts b/apps/web/app/api/v1/tags/[tagId]/route.ts
index 439b6149..29b27218 100644
--- a/apps/web/app/api/v1/tags/[tagId]/route.ts
+++ b/apps/web/app/api/v1/tags/[tagId]/route.ts
@@ -1,6 +1,8 @@
import { NextRequest } from "next/server";
import { buildHandler } from "@/app/api/v1/utils/handler";
+import { zUpdateTagRequestSchema } from "@hoarder/shared/types/tags";
+
export const dynamic = "force-dynamic";
export const GET = (
@@ -20,6 +22,22 @@ export const GET = (
},
});
+export const PATCH = (
+ req: NextRequest,
+ { params }: { params: { tagId: string } },
+) =>
+ buildHandler({
+ req,
+ bodySchema: zUpdateTagRequestSchema.omit({ tagId: true }),
+ handler: async ({ api, body }) => {
+ const tag = await api.tags.update({
+ tagId: params.tagId,
+ ...body!,
+ });
+ return { status: 200, resp: tag };
+ },
+ });
+
export const DELETE = (
req: NextRequest,
{ params }: { params: { tagId: string } },