Replies: 1 comment 4 replies
-
Hello, No it's not possible. If you need types to flow from Server to Client (meaning, implementing server is mandatory), you have tRPC for that or if you want REST APIs there is hono |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The response is linked to a ZodSchema/ZodType, which seems unnecessary and also creates additional work. If I am using an ORM it would be nice to use that type for the model as the response for Zodios instead of duplicating that ORM type into a ZodType.
If the model/endpoint gets a user, you could assign a type of
Omit<User, "password">
. It would cut down on a lot of boilerplate code! I think for a majority of use cases Zod really only needs to be used for data coming into the API, not data being returned. If your database is trusted, running additional validation like ensuring an email is an email seems redundant.Currently, Zod does not allow creating a Zod schema from a type, which could be used as a way to address this.
colinhacks/zod#53
Essentially I want to use my ORM or SQL results as types to drive the type safety of the API response instead of Zod. Is this possible?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions