import { prisma } from "@/lib/db"; import { decodeId } from "@/lib/hashids"; import { withGuards } from "@/lib/api-guards"; type Ctx = { params: Promise<{ chapterId: string }> }; export const GET = withGuards( { rateLimit: { key: "chapter-meta", limit: 60, windowMs: 60_000 } }, async (_request, { params }) => { const { chapterId: raw } = await params; const chapterId = decodeId(raw); if (chapterId === null) { return Response.json({ error: "Invalid chapterId" }, { status: 400 }); } const pages = await prisma.page.findMany({ where: { chapterId }, orderBy: { number: "asc" }, select: { number: true, width: true, height: true }, }); return Response.json(pages); } );