UPDATE: Update readme and Next 16.07 (CVE-2025-66478)
This commit is contained in:
22
src/app/api/[locale]/monster/route.ts
Normal file
22
src/app/api/[locale]/monster/route.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { loadMonster } from "@/lib/loader";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function POST(request: NextRequest, { params }: { params: Promise<{ locale: string }> }) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const monsterIds = body.monsterIds as string[];
|
||||
const { locale } = await params;
|
||||
|
||||
if (!Array.isArray(monsterIds) || monsterIds.some(id => typeof id !== 'string')) {
|
||||
return NextResponse.json({ error: 'Invalid monsterIds' }, { status: 400 });
|
||||
}
|
||||
|
||||
const monsterData = await loadMonster(monsterIds, locale);
|
||||
|
||||
return new NextResponse(JSON.stringify(monsterData), {
|
||||
headers: { "Content-Type": "application/json" }
|
||||
});
|
||||
} catch {
|
||||
return NextResponse.json({ error: 'Failed to load monster data' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user