diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-02-07 11:23:23 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-02-07 11:23:23 +0100 |
commit | 9f10b2928df655c3672d9607e864e667d4bc903a (patch) | |
tree | 7743911b974b3a7fb0d4c7cec2a723942466b7f1 /middlewares/reqValidators/utils.js | |
parent | d7c01e7793d813d804a3b5716d8288f9dcf71a16 (diff) | |
download | PeerTube-9f10b2928df655c3672d9607e864e667d4bc903a.tar.gz PeerTube-9f10b2928df655c3672d9607e864e667d4bc903a.tar.zst PeerTube-9f10b2928df655c3672d9607e864e667d4bc903a.zip |
Remove useless anonymous functions of files
Diffstat (limited to 'middlewares/reqValidators/utils.js')
-rw-r--r-- | middlewares/reqValidators/utils.js | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/middlewares/reqValidators/utils.js b/middlewares/reqValidators/utils.js index c88f6df2e..46c982571 100644 --- a/middlewares/reqValidators/utils.js +++ b/middlewares/reqValidators/utils.js | |||
@@ -1,27 +1,25 @@ | |||
1 | ;(function () { | 1 | 'use strict' |
2 | 'use strict' | ||
3 | 2 | ||
4 | var util = require('util') | 3 | var util = require('util') |
5 | 4 | ||
6 | var logger = require('../../helpers/logger') | 5 | var logger = require('../../helpers/logger') |
7 | 6 | ||
8 | var reqValidatorsUtils = { | 7 | var reqValidatorsUtils = { |
9 | checkErrors: checkErrors | 8 | checkErrors: checkErrors |
10 | } | 9 | } |
11 | |||
12 | function checkErrors (req, res, next, status_code) { | ||
13 | if (status_code === undefined) status_code = 400 | ||
14 | var errors = req.validationErrors() | ||
15 | 10 | ||
16 | if (errors) { | 11 | function checkErrors (req, res, next, status_code) { |
17 | logger.warn('Incorrect request parameters', { path: req.originalUrl, err: errors }) | 12 | if (status_code === undefined) status_code = 400 |
18 | return res.status(status_code).send('There have been validation errors: ' + util.inspect(errors)) | 13 | var errors = req.validationErrors() |
19 | } | ||
20 | 14 | ||
21 | return next() | 15 | if (errors) { |
16 | logger.warn('Incorrect request parameters', { path: req.originalUrl, err: errors }) | ||
17 | return res.status(status_code).send('There have been validation errors: ' + util.inspect(errors)) | ||
22 | } | 18 | } |
23 | 19 | ||
24 | // --------------------------------------------------------------------------- | 20 | return next() |
21 | } | ||
22 | |||
23 | // --------------------------------------------------------------------------- | ||
25 | 24 | ||
26 | module.exports = reqValidatorsUtils | 25 | module.exports = reqValidatorsUtils |
27 | })() | ||