Parent Directory
|
Revision Log
feat(api): auth middleware
1 | rakin | 349 | import { NextFunction, Request, Response } from "express"; |
2 | import { validationResult } from "express-validator"; | ||
3 | |||
4 | export default function ValidatorError(request: Request, res: Response, next: NextFunction) { | ||
5 | const errors = validationResult(request); | ||
6 | |||
7 | if (!errors.isEmpty()) { | ||
8 | return res.status(422).send({ errors: errors.array(), error_type: 'validation' }); | ||
9 | } | ||
10 | |||
11 | next(); | ||
12 | } |
[email protected] | ViewVC Help |
Powered by ViewVC 1.1.26 |