diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-01-31 11:23:52 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-01-31 11:23:52 +0100 |
commit | c45f7f84001c2731909db04dd82e1c1f290386eb (patch) | |
tree | b7e57420a1f65dfbbacc1a532bf489c9bea6125d /middlewares/reqValidators/remote.js | |
parent | cda021079ff455cc0fd0eb95a5395fa808ab63d1 (diff) | |
download | PeerTube-c45f7f84001c2731909db04dd82e1c1f290386eb.tar.gz PeerTube-c45f7f84001c2731909db04dd82e1c1f290386eb.tar.zst PeerTube-c45f7f84001c2731909db04dd82e1c1f290386eb.zip |
Infile code reorganization
Diffstat (limited to 'middlewares/reqValidators/remote.js')
-rw-r--r-- | middlewares/reqValidators/remote.js | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/middlewares/reqValidators/remote.js b/middlewares/reqValidators/remote.js index 4b161e292..9b61481ad 100644 --- a/middlewares/reqValidators/remote.js +++ b/middlewares/reqValidators/remote.js | |||
@@ -4,20 +4,13 @@ | |||
4 | var checkErrors = require('./utils').checkErrors | 4 | var checkErrors = require('./utils').checkErrors |
5 | var logger = require('../../helpers/logger') | 5 | var logger = require('../../helpers/logger') |
6 | 6 | ||
7 | var remote = {} | 7 | var reqValidatorsRemote = { |
8 | 8 | remoteVideosAdd: remoteVideosAdd, | |
9 | remote.secureRequest = function (req, res, next) { | 9 | remoteVideosRemove: remoteVideosRemove, |
10 | req.checkBody('signature.url', 'Should have a signature url').isURL() | 10 | secureRequest: secureRequest |
11 | req.checkBody('signature.signature', 'Should have a signature').notEmpty() | ||
12 | req.checkBody('key', 'Should have a key').notEmpty() | ||
13 | req.checkBody('data', 'Should have data').notEmpty() | ||
14 | |||
15 | logger.debug('Checking secureRequest parameters', { parameters: { data: req.body.data, keyLength: req.body.key.length } }) | ||
16 | |||
17 | checkErrors(req, res, next) | ||
18 | } | 11 | } |
19 | 12 | ||
20 | remote.remoteVideosAdd = function (req, res, next) { | 13 | function remoteVideosAdd (req, res, next) { |
21 | req.checkBody('data').isArray() | 14 | req.checkBody('data').isArray() |
22 | req.checkBody('data').eachIsRemoteVideosAddValid() | 15 | req.checkBody('data').eachIsRemoteVideosAddValid() |
23 | 16 | ||
@@ -26,7 +19,7 @@ | |||
26 | checkErrors(req, res, next) | 19 | checkErrors(req, res, next) |
27 | } | 20 | } |
28 | 21 | ||
29 | remote.remoteVideosRemove = function (req, res, next) { | 22 | function remoteVideosRemove (req, res, next) { |
30 | req.checkBody('data').isArray() | 23 | req.checkBody('data').isArray() |
31 | req.checkBody('data').eachIsRemoteVideosRemoveValid() | 24 | req.checkBody('data').eachIsRemoteVideosRemoveValid() |
32 | 25 | ||
@@ -35,5 +28,18 @@ | |||
35 | checkErrors(req, res, next) | 28 | checkErrors(req, res, next) |
36 | } | 29 | } |
37 | 30 | ||
38 | module.exports = remote | 31 | function secureRequest (req, res, next) { |
32 | req.checkBody('signature.url', 'Should have a signature url').isURL() | ||
33 | req.checkBody('signature.signature', 'Should have a signature').notEmpty() | ||
34 | req.checkBody('key', 'Should have a key').notEmpty() | ||
35 | req.checkBody('data', 'Should have data').notEmpty() | ||
36 | |||
37 | logger.debug('Checking secureRequest parameters', { parameters: { data: req.body.data, keyLength: req.body.key.length } }) | ||
38 | |||
39 | checkErrors(req, res, next) | ||
40 | } | ||
41 | |||
42 | // --------------------------------------------------------------------------- | ||
43 | |||
44 | module.exports = reqValidatorsRemote | ||
39 | })() | 45 | })() |