Compile Zod (30x faster Zod validation) (opens in new tab)
Lets start with a code example: import \{ pool, sql \} from \"\./db\.js\"; import \{ z \} from \"zod\"; const getUser = \(id: number\) =\> \{ return pool\.one\( sql\.type\( z\.object\(\{ id: z\.number\(\), name: z\.string\(\), \}\), \)\`SELECT id, name FROM users WHERE id = $\{id\}\`, \); \}; There are two performance issues in the above code: z\.object\(\{\}\) initialization data validation using Zod parser \(interpretation\) Initialization The first one is something you can solve simply by ...
Read the original article