News for hackers. Stuff that matters.
Re:Zod: TypeScript-first schema validation with static type ... by bjacobso on Wednesday October 09, 2024 @02:10PM (#41790939)
I think you are looking for https://ts-rest.com/
Re:Zod: TypeScript-first schema validation with static type ... by kaoD on Wednesday October 09, 2024 @02:15PM (#41790984)
Nice. I'm looking to migrate away from a legacy custom framework over Express and this could help.

If someone has tried both, can anyone share how it compares with tRPC[0]?

[0] https://trpc.io/

Re:Zod: TypeScript-first schema validation with static type ... by bjacobso on Wednesday October 09, 2024 @02:21PM (#41791036)
From my understanding trpc is very similar, however, the rpc mechanism is not a standard. ts-rest produces openapi schemas and speaks REST over http, as well as a typed client.

That being said, I am actually slowly migrating off ts-rest and adopting @effect/schema and @effect/platform/HttpApi, I foresee this being the direction the typescript ecosystem heads in over the next few years. However, the APIs are not stable yet and it has a bit of a learning curve, so would not adopt lightly

Re:Zod: TypeScript-first schema validation with static type ... by AWebOfBrown on Wednesday October 09, 2024 @05:52PM (#41793078)
I really wanted to adopt tRPC but the deal breaker was it being opinionated on status codes without allowing configurability. Because I needed to meet an existing API spec, that meant ts-rest was a better option. I think there's an aditional option with a native spec generator in frameworks like Hono, and maybe Elysia.