Validate once at the edge, then trust the types
Parsing the same payload with a schema in three layers is slow and it means nobody trusts the layer above. Parse where data enters, request bodies, environment, external APIs, and pass typed values inward.
const body = CreateOrder.parse(await req.json()); // the only parse
await createOrder(body); // typed from here onz.infer<typeof CreateOrder> is the type the inner code takes. If a value has that type, it was validated, by construction.
typescriptvalidation