gajus.medium.com

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
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help