diff options
Diffstat (limited to 'server/middlewares/reqValidators/remote.js')
-rw-r--r-- | server/middlewares/reqValidators/remote.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/server/middlewares/reqValidators/remote.js b/server/middlewares/reqValidators/remote.js new file mode 100644 index 000000000..88de16b49 --- /dev/null +++ b/server/middlewares/reqValidators/remote.js | |||
@@ -0,0 +1,43 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | var checkErrors = require('./utils').checkErrors | ||
4 | var logger = require('../../helpers/logger') | ||
5 | |||
6 | var reqValidatorsRemote = { | ||
7 | remoteVideosAdd: remoteVideosAdd, | ||
8 | remoteVideosRemove: remoteVideosRemove, | ||
9 | secureRequest: secureRequest | ||
10 | } | ||
11 | |||
12 | function remoteVideosAdd (req, res, next) { | ||
13 | req.checkBody('data').isArray() | ||
14 | req.checkBody('data').eachIsRemoteVideosAddValid() | ||
15 | |||
16 | logger.debug('Checking remoteVideosAdd parameters', { parameters: req.body }) | ||
17 | |||
18 | checkErrors(req, res, next) | ||
19 | } | ||
20 | |||
21 | function remoteVideosRemove (req, res, next) { | ||
22 | req.checkBody('data').isArray() | ||
23 | req.checkBody('data').eachIsRemoteVideosRemoveValid() | ||
24 | |||
25 | logger.debug('Checking remoteVideosRemove parameters', { parameters: req.body }) | ||
26 | |||
27 | checkErrors(req, res, next) | ||
28 | } | ||
29 | |||
30 | function secureRequest (req, res, next) { | ||
31 | req.checkBody('signature.url', 'Should have a signature url').isURL() | ||
32 | req.checkBody('signature.signature', 'Should have a signature').notEmpty() | ||
33 | req.checkBody('key', 'Should have a key').notEmpty() | ||
34 | req.checkBody('data', 'Should have data').notEmpty() | ||
35 | |||
36 | logger.debug('Checking secureRequest parameters', { parameters: { data: req.body.data, keyLength: req.body.key.length } }) | ||
37 | |||
38 | checkErrors(req, res, next) | ||
39 | } | ||
40 | |||
41 | // --------------------------------------------------------------------------- | ||
42 | |||
43 | module.exports = reqValidatorsRemote | ||