Skip to content

Commit f9a1cb3

Browse files
committed
refactor: remove unused parseBody function and related zod import
1 parent 081ccdb commit f9a1cb3

1 file changed

Lines changed: 1 addition & 19 deletions

File tree

adminforth/modules/utils.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import crypto from 'crypto';
66
import { AdminForthConfig, AdminForthResource, AdminForthResourceColumnInputCommon,Filters, IAdminForth, Predicate } from '../index.js';
77
import { RateLimiterMemory, RateLimiterAbstract } from "rate-limiter-flexible";
88
import { PERIOD_UNITS, type PeriodString, type PeriodUnit } from '../types/Back.js';
9-
import { z } from "zod";
109

1110
// @ts-ignore-next-line
1211

@@ -646,21 +645,4 @@ export function applyRegexValidation(value, validation) {
646645
${horizontal}
647646
${RESET}
648647
`;
649-
}
650-
651-
652-
export function parseBody<T>(
653-
schema: z.ZodType<T>,
654-
body: unknown,
655-
response: { setStatus: (code: number, message: string) => void },
656-
): { ok: true; data: T } | { ok: false; error: { error: string; details: unknown } } {
657-
const parsed = schema.safeParse(body ?? {});
658-
if (!parsed.success) {
659-
response.setStatus(400, '');
660-
return {
661-
ok: false,
662-
error: { error: 'Request body validation failed', details: parsed.error.issues },
663-
};
664-
}
665-
return { ok: true, data: parsed.data };
666-
}
648+
}

0 commit comments

Comments
 (0)