(schema: AnySchema)
| 3 | import log from "../logger"; |
| 4 | |
| 5 | const validate = (schema: AnySchema) => async ( |
| 6 | req: Request, |
| 7 | res: Response, |
| 8 | next: NextFunction |
| 9 | ) => { |
| 10 | try { |
| 11 | await schema.validate({ |
| 12 | body: req.body, |
| 13 | query: req.query, |
| 14 | params: req.params, |
| 15 | }); |
| 16 | |
| 17 | return next(); |
| 18 | } catch (e) { |
| 19 | log.error(e); |
| 20 | return res.status(400).send(e.errors); |
| 21 | } |
| 22 | }; |
| 23 | |
| 24 | export default validate; |
nothing calls this directly
no outgoing calls
no test coverage detected