aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/reqValidators/remote.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/reqValidators/remote.js')
-rw-r--r--server/middlewares/reqValidators/remote.js43
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
3var checkErrors = require('./utils').checkErrors
4var logger = require('../../helpers/logger')
5
6var reqValidatorsRemote = {
7 remoteVideosAdd: remoteVideosAdd,
8 remoteVideosRemove: remoteVideosRemove,
9 secureRequest: secureRequest
10}
11
12function 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
21function 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
30function 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
43module.exports = reqValidatorsRemote