UNPKG

burger-api

Version:

<div align="center"> <a href="https://burger-api.com"> <img src="https://github.com/user-attachments/assets/0d9b376e-1d89-479a-aa7f-e7ee3c6b2342" alt="BurgerAPI"/> </a> </div>

15 lines (14 loc) 721 B
import type { RouteSchema, Middleware } from '../types/index'; /** * createValidationMiddleware: * - Precompute a smaller runtime descriptor per method to avoid * repeatedly touching the full schema object on every request. * - Uses safeParse (sync) for Zod schemas (no try/catch around safeParse). * - Parses querystring manually (no URL constructor, no throw). * - Lazily allocates the errors container only when needed. * - Avoids unnecessary object allocations for successful paths. * * @param schema - The route schema to validate the request against. * @returns The middleware function that validates the request. */ export declare function createValidationMiddleware(schema: RouteSchema): Middleware;