1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00
Peertube/server/middlewares/validators/utils.ts
2017-06-10 22:15:25 +02:00

22 lines
619 B
TypeScript

import 'express-validator'
import * as express from 'express'
import { inspect } from 'util'
import { logger } from '../../helpers'
function checkErrors (req: express.Request, res: express.Response, next: express.NextFunction, statusCode = 400) {
const errors = req.validationErrors()
if (errors) {
logger.warn('Incorrect request parameters', { path: req.originalUrl, err: errors })
return res.status(statusCode).send('There have been validation errors: ' + inspect(errors))
}
return next()
}
// ---------------------------------------------------------------------------
export {
checkErrors
}