zod, typebox or hand-written types for 40 endpoints with 2 devs and no time Schema Types
Internal API, about 40 endpoints, two of us. I want runtime validation at the boundary and types that cannot drift from it. There is an OpenAPI document generated from the handlers today but nobody fully trusts it.
Constraints: some of these schemas get imported into the browser bundle, and our type-check time is already not great. Leaning Zod because everyone knows it, but I have read enough complaints about its compile cost to want a second opinion.
@orm_tamsin · 5mo ago · 3 replies
Zod, and for two people it is not close. Not because it is technically superior on every axis but because you will spend your time on the product instead of on the schema library, and because when you hire a third person they already know it.
The honest trade-offs:
--generateTrace. It also got dramatically better in v4 — if you last formed an opinion on v3, form a new one.Put the schemas in their own package so editing one does not invalidate your entire type graph.
Reply
Report
@visa_run_val · 5mo ago
The v3 versus v4 point is fair, most of what I had read was old. Going to prototype five endpoints and actually time the check before committing to all forty.
Reply
Report
@seedstart_sim · 6mo ago
Timing five endpoints will underestimate it — the cost is superlinear in some of these chains, so measure at twenty if you can stomach it. Still the right instinct, just do not conclude from a small sample that it stays cheap.
Reply
Report