Hoping this lets it build.

This commit is contained in:
Gabriel Brown 2024-07-20 21:23:01 -05:00
parent 620182fe02
commit 2f6f92045f

View File

@ -28,16 +28,16 @@ export const POST = async (request: Request) => {
if (apiKey !== 'zAf4vYVN2pszrK') {
return NextResponse.json({ message: 'Unauthorized' }, { status: 401 });
}
const body: unknown = await request.json();
// Type assert body to RequestBody only after validation
if (typeof body !== 'object' || body === null || !Array.isArray((body as { technicians?: unknown }).technicians)) {
// Validate the body and its technicians property
if (typeof body !== 'object' || body === null || !Array.isArray((body as { technicians?: unknown[] }).technicians)) {
return NextResponse.json({ message: 'Invalid input: expecting an array of technicians.' }, { status: 400 });
}
const technicians: unknown[] = (body as { technicians: unknown }).technicians;
const technicians = (body as { technicians: unknown[] }).technicians;
if (!technicians.every(isTechnician)) {
return NextResponse.json({ message: 'Invalid input: missing name or status for a technician.' }, { status: 400 });
}