Type-safe Fastify

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ธ.ค. 2024

ความคิดเห็น • 20

  • @theo_ludwig
    @theo_ludwig ปีที่แล้ว +2

    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.

  • @franky47
    @franky47 ปีที่แล้ว +2

    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.

    • @adventuresinnodeland
      @adventuresinnodeland  ปีที่แล้ว

      I think it’s possible to use Zod! Check out www.npmjs.com/package/fastify-type-provider-zod

  • @teerapatprommarak2070
    @teerapatprommarak2070 ปีที่แล้ว

    Thank you Matteo, this is very useful!

  • @bharatchakrabarthy7571
    @bharatchakrabarthy7571 7 หลายเดือนก่อน

    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?

  • @aristide_F
    @aristide_F ปีที่แล้ว +2

    Thank you so much 😊
    Oh please can we have something as cool as this with mercurius ?! Both typesafety and setup ?! Please

  • @EddyVinck
    @EddyVinck ปีที่แล้ว

    Great video, thanks Matteo!

  • @boscodomingo
    @boscodomingo 11 หลายเดือนก่อน +1

    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!

  • @anze2455
    @anze2455 ปีที่แล้ว

    Great video, dude! Keep at it ;)

  • @cornelcristianfilip5048
    @cornelcristianfilip5048 3 หลายเดือนก่อน

    Beautiful!

  • @mariolazzari
    @mariolazzari 9 หลายเดือนก่อน

    Bravissimo!

  • @thelinuxlich
    @thelinuxlich ปีที่แล้ว

    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 :(

    • @chack-hq1oq
      @chack-hq1oq ปีที่แล้ว

      Why should it error? Extra properties will be removed from the response

    • @thelinuxlich
      @thelinuxlich ปีที่แล้ว

      @@chack-hq1oq in compile-time if it's indirect assignment

  • @Joshua-yc9ei
    @Joshua-yc9ei ปีที่แล้ว

    This is awesome

  • @suryapratap3622
    @suryapratap3622 ปีที่แล้ว

    awesome