- Sign all image URLs server-side with 60s expiry presigned URLs - Add /api/pages endpoint for batched page fetching (7 per batch) - PageReader prefetches next batch when user scrolls to 3rd page - Move chapter count badge outside overflow-hidden for 3D effect - Fix missing URL signing on search and genre pages - Extract signCoverUrls helper to reduce duplication - Clamp API limit param to prevent abuse Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
42 lines
963 B
TypeScript
42 lines
963 B
TypeScript
import { prisma } from "@/lib/db";
|
|
import { signCoverUrls } from "@/lib/r2";
|
|
import { NextRequest } from "next/server";
|
|
|
|
export async function GET() {
|
|
const manga = await prisma.manga.findMany({
|
|
orderBy: { updatedAt: "desc" },
|
|
include: {
|
|
_count: { select: { chapters: true } },
|
|
},
|
|
});
|
|
|
|
const signedManga = await signCoverUrls(manga);
|
|
|
|
return Response.json(signedManga);
|
|
}
|
|
|
|
export async function POST(request: NextRequest) {
|
|
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 });
|
|
}
|