Aquila169 / zod-express-middleware

Express middleware to validate requests using zod schema's.
MIT License
86 stars 13 forks source link

getting type for body , query and params #12

Open VenomFate-619 opened 1 year ago

VenomFate-619 commented 1 year ago

However, if the code for your endpoint is in a separate file, typings will not be automatically available. This is where the TypedRequest, TypedRequestBody etc. types come in: the typeof a ZodSchema can be passed into the TypedRequest, providing your function with typings. An example:

if I use something like this, do I get the types?

const {body , query , params} = validateRequest(schema , req) // directly using in the controller instead of the middleware.

I think for this there would be a need of req argument to be passed