mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 18:29:27 +02:00
reqValidators --> validators
This commit is contained in:
parent
69b0a27cbb
commit
fc51fde048
13 changed files with 54 additions and 53 deletions
|
@ -1,25 +0,0 @@
|
|||
'use strict'
|
||||
|
||||
const util = require('util')
|
||||
|
||||
const logger = require('../../helpers/logger')
|
||||
|
||||
const reqValidatorsUtils = {
|
||||
checkErrors: checkErrors
|
||||
}
|
||||
|
||||
function checkErrors (req, res, next, statusCode) {
|
||||
if (statusCode === undefined) 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: ' + util.inspect(errors))
|
||||
}
|
||||
|
||||
return next()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
module.exports = reqValidatorsUtils
|
Loading…
Add table
Add a link
Reference in a new issue