This commit is contained in:
2025-01-07 20:30:40 +01:00
parent 9c82f5e5c6
commit 68b0d29b3d
15 changed files with 2884 additions and 48 deletions
+17
View File
@@ -0,0 +1,17 @@
import { getBlog, getBlogs } from "@/blogApi";
import { notion, databaseId, n2m } from "@/notion";
export async function GET(request: Request) {
const url = new URL(request.url);
const id = url.searchParams.get("id");
if (id !== null) {
let [status, data] = await getBlog(notion, n2m, id);
return Response.json(data, { status });
} else {
var cursor = url.searchParams.get("cursor") || undefined;
if (cursor === "") cursor = undefined;
const size = parseInt(url.searchParams.get("size") || "5");
let [status, response] = await getBlogs(notion, databaseId, cursor, size);
return Response.json(response, { status });
}
}