Fix: Server attempts to create setup executable and finds undefined #83 (#84)

This commit is contained in:
DecDuck
2025-06-06 09:18:58 +10:00
committed by GitHub
parent 9e929ddf98
commit c3005813a2
2 changed files with 16 additions and 5 deletions
+13 -2
View File
@@ -19,9 +19,20 @@ export async function readDropValidatedBody<T>(
event: H3Event,
validate: (data: object) => T,
): Promise<T> {
const _body = await readBody(event);
const body = await readBody(event);
try {
return validate(_body);
// Delete all values that are 'null'
if (typeof body === "object" && !Array.isArray(body) && body !== null) {
for (const [key, value] of Object.entries(body) as Array<
[string, unknown]
>) {
if (value === null) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete body[key];
}
}
}
return validate(body);
} catch (e) {
const t = await useTranslation(event);