aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/app/api/v1/lists
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/app/api/v1/lists')
-rw-r--r--apps/web/app/api/v1/lists/[listId]/bookmarks/[bookmarkId]/route.ts35
-rw-r--r--apps/web/app/api/v1/lists/[listId]/bookmarks/route.ts19
-rw-r--r--apps/web/app/api/v1/lists/[listId]/route.ts55
-rw-r--r--apps/web/app/api/v1/lists/route.ts26
4 files changed, 0 insertions, 135 deletions
diff --git a/apps/web/app/api/v1/lists/[listId]/bookmarks/[bookmarkId]/route.ts b/apps/web/app/api/v1/lists/[listId]/bookmarks/[bookmarkId]/route.ts
deleted file mode 100644
index 6efe2055..00000000
--- a/apps/web/app/api/v1/lists/[listId]/bookmarks/[bookmarkId]/route.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { NextRequest } from "next/server";
-import { buildHandler } from "@/app/api/v1/utils/handler";
-
-export const dynamic = "force-dynamic";
-
-export const PUT = (
- req: NextRequest,
- { params }: { params: { listId: string; bookmarkId: string } },
-) =>
- buildHandler({
- req,
- handler: async ({ api }) => {
- // TODO: PUT is supposed to be idempotent, but we currently fail if the bookmark is already in the list.
- await api.lists.addToList({
- listId: params.listId,
- bookmarkId: params.bookmarkId,
- });
- return { status: 204 };
- },
- });
-
-export const DELETE = (
- req: NextRequest,
- { params }: { params: { listId: string; bookmarkId: string } },
-) =>
- buildHandler({
- req,
- handler: async ({ api }) => {
- await api.lists.removeFromList({
- listId: params.listId,
- bookmarkId: params.bookmarkId,
- });
- return { status: 204 };
- },
- });
diff --git a/apps/web/app/api/v1/lists/[listId]/bookmarks/route.ts b/apps/web/app/api/v1/lists/[listId]/bookmarks/route.ts
deleted file mode 100644
index daf78449..00000000
--- a/apps/web/app/api/v1/lists/[listId]/bookmarks/route.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { NextRequest } from "next/server";
-import { buildHandler } from "@/app/api/v1/utils/handler";
-import { adaptPagination, zPagination } from "@/app/api/v1/utils/pagination";
-import { zGetBookmarkQueryParamsSchema } from "@/app/api/v1/utils/types";
-
-export const dynamic = "force-dynamic";
-
-export const GET = (req: NextRequest, params: { params: { listId: string } }) =>
- buildHandler({
- req,
- searchParamsSchema: zPagination.and(zGetBookmarkQueryParamsSchema),
- handler: async ({ api, searchParams }) => {
- const bookmarks = await api.bookmarks.getBookmarks({
- listId: params.params.listId,
- ...searchParams,
- });
- return { status: 200, resp: adaptPagination(bookmarks) };
- },
- });
diff --git a/apps/web/app/api/v1/lists/[listId]/route.ts b/apps/web/app/api/v1/lists/[listId]/route.ts
deleted file mode 100644
index 2cddbfdb..00000000
--- a/apps/web/app/api/v1/lists/[listId]/route.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import { NextRequest } from "next/server";
-import { buildHandler } from "@/app/api/v1/utils/handler";
-
-import { zEditBookmarkListSchema } from "@karakeep/shared/types/lists";
-
-export const dynamic = "force-dynamic";
-
-export const GET = (
- req: NextRequest,
- { params }: { params: { listId: string } },
-) =>
- buildHandler({
- req,
- handler: async ({ api }) => {
- const list = await api.lists.get({
- listId: params.listId,
- });
- return {
- status: 200,
- resp: list,
- };
- },
- });
-
-export const PATCH = (
- req: NextRequest,
- { params }: { params: { listId: string } },
-) =>
- buildHandler({
- req,
- bodySchema: zEditBookmarkListSchema.omit({ listId: true }),
- handler: async ({ api, body }) => {
- const list = await api.lists.edit({
- ...body!,
- listId: params.listId,
- });
- return { status: 200, resp: list };
- },
- });
-
-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/lists/route.ts b/apps/web/app/api/v1/lists/route.ts
deleted file mode 100644
index 5def2506..00000000
--- a/apps/web/app/api/v1/lists/route.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { NextRequest } from "next/server";
-
-import { zNewBookmarkListSchema } from "@karakeep/shared/types/lists";
-
-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 };
- },
- });
-
-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 };
- },
- });