fix: BigInt serialization in shoot-log API responses
Deploy / deploy (push) Successful in 2m41s

This commit is contained in:
twotalesanimation
2026-07-11 19:38:54 +02:00
parent 3ff70cc5e3
commit b9953ff543
3 changed files with 22 additions and 6 deletions
+8 -2
View File
@@ -6,6 +6,12 @@ function requireRole(role: string) {
return ["ADMIN", "PRODUCER", "SUPERVISOR"].includes(role);
}
/** Convert BigInt values to Number so JSON.stringify doesn't throw */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function bigIntSafe(obj: any): any {
return JSON.parse(JSON.stringify(obj, (_, v) => (typeof v === "bigint" ? Number(v) : v)));
}
function sanitize(data: Record<string, unknown>) {
const allowed = new Set([
"scene","shotLabel","unitLabel","cameraLetter","clipName","roll","cameraModel",
@@ -49,7 +55,7 @@ export async function GET(
});
if (!take) return NextResponse.json({ error: "Not found" }, { status: 404 });
return NextResponse.json({ take });
return NextResponse.json(bigIntSafe({ take }));
}
// PATCH /api/shoot-log/takes/[takeId]
@@ -71,7 +77,7 @@ export async function PATCH(
include: { attachments: { orderBy: { sortOrder: "asc" } } },
});
return NextResponse.json({ take });
return NextResponse.json(bigIntSafe({ take }));
}
// DELETE /api/shoot-log/takes/[takeId]