Add blog CMS with tracked public posts
Build Check / build (pull_request) Successful in 34s
Build Check / push-image (pull_request) Has been skipped
Build Check / deploy-coolify (pull_request) Has been skipped

This commit is contained in:
2026-07-17 22:02:25 +00:00
parent ef63164d58
commit 912e5edb81
24 changed files with 1667 additions and 36 deletions
+27
View File
@@ -0,0 +1,27 @@
import { NextResponse } from "next/server";
import { prisma } from "@/lib/prisma";
import { parseBlogPost } from "@/lib/dto";
import { guard, run, readBody } from "@/lib/adminRoute";
export async function GET() {
const denied = await guard();
if (denied) return denied;
return run(async () => {
const posts = await prisma.blogPost.findMany({
orderBy: [{ updatedAt: "desc" }],
});
return NextResponse.json(posts);
});
}
export async function POST(req: Request) {
const denied = await guard();
if (denied) return denied;
return run(async () => {
const data = parseBlogPost(await readBody(req));
const created = await prisma.blogPost.create({ data });
return NextResponse.json(created, { status: 201 });
});
}