TypeScript provides great type safety as long as your code doesn't do any I/O operations. However, most Node.JS applications do tons of I/O - reading from a database, handling HTTP requests, reading messages from queues etc. How can we guarantee that the shape of objects we receive matches our types? When working with tens or hundreds of microservices, that could really become a problem.
Enter Zod - a schema validation library with built in type inference mechanism. With Zod, you can ensure that external inputs conform to your specified types, preventing the ingress of invalid data.
In this presentation, I will explain the challenge of maintaining type safety across I/O operations. I will provide a brief demonstration of Zod, showcasing its capabilities, and then explain how we leverage Zod at RiseUp, to prevent invalid data - whether from HTTP request or database queries - from reaching our business logic.
I'm a Principal Engineer at RiseUp, an Israeli Fintech company. I have over 20 years of experience in software engineering, with over 10 years specifically focused on Node.js. I'm passionate about building products from "zero to one" that have a real impact on people's lives. I love geeking out about distributed systems architecture and type safety. In my spare time, I enjoy playing chess, reading fantasy books, and working in the communal garden next to my home.