Hoping this lets it build.
This commit is contained in:
parent
620182fe02
commit
2f6f92045f
@ -31,12 +31,12 @@ export const POST = async (request: Request) => {
|
|||||||
|
|
||||||
const body: unknown = await request.json();
|
const body: unknown = await request.json();
|
||||||
|
|
||||||
// Type assert body to RequestBody only after validation
|
// Validate the body and its technicians property
|
||||||
if (typeof body !== 'object' || body === null || !Array.isArray((body as { technicians?: unknown }).technicians)) {
|
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 });
|
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)) {
|
if (!technicians.every(isTechnician)) {
|
||||||
return NextResponse.json({ message: 'Invalid input: missing name or status for a technician.' }, { status: 400 });
|
return NextResponse.json({ message: 'Invalid input: missing name or status for a technician.' }, { status: 400 });
|
||||||
|
Loading…
Reference in New Issue
Block a user