import { prisma } from "@/lib/db"; import { withGuards } from "@/lib/api-guards"; export const GET = withGuards( { rateLimit: { key: "manga-list", limit: 30, windowMs: 60_000 } }, async () => { const manga = await prisma.manga.findMany({ orderBy: { updatedAt: "desc" }, include: { _count: { select: { chapters: true } }, }, }); return Response.json(manga); } ); export const POST = withGuards({}, async (request) => { const body = await request.json(); const { title, description, coverUrl, slug, status } = body; if (!title || !description || !coverUrl || !slug) { return Response.json( { error: "Missing required fields: title, description, coverUrl, slug" }, { status: 400 } ); } const manga = await prisma.manga.create({ data: { title, description, coverUrl, slug, status: status || "PUBLISHED", }, }); return Response.json(manga, { status: 201 }); });