Well explained, thanks for the video and the amazing DX (Developer Experience)! With Fastify, it's easy to write type-safe and well documented REST APIs.
This is great, I didn't know the type of schema arguments was enough to type the request {params,headers,query,body} and response {headers,body}. I use Zod and convert its schemas to JSON schemas to pass to Fastify, but I also have to pass the derived types to the .{get,post,delete,etc} functions as generics, as I believe the resulting JSON schemas aren't strongly typed anymore. I'll see if I can port your type provider approach to support Zod.
Hi wonderful video! I was just wondering if I use typebox typeproovider, will typebox be used for schema validation and serializarion too? From what I understand from docs is that fastify uses ajv under the hood for schema validation and that it is very fast, is typebox similar in performance if it's used rather than ajv?
How about when you don't have everything in one file? I lose the compile-time types then, even though the Fastify instance at runtime has the correct type provider registered Edit: I'm dumb. You need to use the FastifyPluginAsyncTypebox type for your plugins and you're good!
There is a issue in your example, if I store the response in a variable with a additional field, like const foo = { hello: "world", bla: "baz" }; return foo, the response doesn't error at compile-time :(
Well explained, thanks for the video and the amazing DX (Developer Experience)!
With Fastify, it's easy to write type-safe and well documented REST APIs.
This is great, I didn't know the type of schema arguments was enough to type the request {params,headers,query,body} and response {headers,body}. I use Zod and convert its schemas to JSON schemas to pass to Fastify, but I also have to pass the derived types to the .{get,post,delete,etc} functions as generics, as I believe the resulting JSON schemas aren't strongly typed anymore. I'll see if I can port your type provider approach to support Zod.
I think it’s possible to use Zod! Check out www.npmjs.com/package/fastify-type-provider-zod
Thank you Matteo, this is very useful!
Hi wonderful video! I was just wondering if I use typebox typeproovider, will typebox be used for schema validation and serializarion too? From what I understand from docs is that fastify uses ajv under the hood for schema validation and that it is very fast, is typebox similar in performance if it's used rather than ajv?
Thank you so much 😊
Oh please can we have something as cool as this with mercurius ?! Both typesafety and setup ?! Please
Great video, thanks Matteo!
Glad you liked it!
How about when you don't have everything in one file? I lose the compile-time types then, even though the Fastify instance at runtime has the correct type provider registered
Edit: I'm dumb. You need to use the FastifyPluginAsyncTypebox type for your plugins and you're good!
Great video, dude! Keep at it ;)
Beautiful!
Bravissimo!
thanks!
There is a issue in your example, if I store the response in a variable with a additional field, like const foo = { hello: "world", bla: "baz" }; return foo, the response doesn't error at compile-time :(
Why should it error? Extra properties will be removed from the response
@@chack-hq1oq in compile-time if it's indirect assignment
This is awesome
awesome