RobinTail/express-zod-api

How to get req.query req.params if we dont know the shape

fbritoferreira opened this issue · 0 comments

I have an app where we want to accept a wide number of params and query and pull it all together as a object.

I was wandering if i we could use input: z.record(z.string(), z.string()) it would accept them and pull those together

Existing Middleware

       const options = {};

        Object.keys(req.query).forEach(param => options[param] = req.query[param]);
        Object.keys(req.params).forEach(param => options[param] = req.params[param]);

        req.opts = options;