aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/remote.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-07-01 16:16:40 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-07-01 16:16:40 +0200
commitfc51fde048f2c3ce1dd3e85f5528335040bae894 (patch)
tree6de1eeac1291d9398cc99cda926b189c39b3ea0b /server/middlewares/validators/remote.js
parent69b0a27cbbd69ca019eb7db5f917b1dd06dc82cd (diff)
downloadPeerTube-fc51fde048f2c3ce1dd3e85f5528335040bae894.tar.gz
PeerTube-fc51fde048f2c3ce1dd3e85f5528335040bae894.tar.zst
PeerTube-fc51fde048f2c3ce1dd3e85f5528335040bae894.zip
reqValidators --> validators
Diffstat (limited to 'server/middlewares/validators/remote.js')
-rw-r--r--server/middlewares/validators/remote.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/server/middlewares/validators/remote.js b/server/middlewares/validators/remote.js
new file mode 100644
index 000000000..1be119458
--- /dev/null
+++ b/server/middlewares/validators/remote.js
@@ -0,0 +1,41 @@
1'use strict'
2
3const checkErrors = require('./utils').checkErrors
4const logger = require('../../helpers/logger')
5
6const validatorsRemote = {
7 dataToDecrypt: dataToDecrypt,
8 remoteVideos: remoteVideos,
9 signature: signature
10}
11
12function dataToDecrypt (req, res, next) {
13 req.checkBody('key', 'Should have a key').notEmpty()
14 req.checkBody('data', 'Should have data').notEmpty()
15
16 logger.debug('Checking dataToDecrypt parameters', { parameters: { keyLength: req.body.key.length, bodyLength: req.body.data.length } })
17
18 checkErrors(req, res, next)
19}
20
21function remoteVideos (req, res, next) {
22 req.checkBody('data').isArray()
23 req.checkBody('data').isEachRemoteVideosValid()
24
25 logger.debug('Checking remoteVideos parameters', { parameters: req.body })
26
27 checkErrors(req, res, next)
28}
29
30function signature (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
34 logger.debug('Checking signature parameters', { parameters: { signatureUrl: req.body.signature.url } })
35
36 checkErrors(req, res, next)
37}
38
39// ---------------------------------------------------------------------------
40
41module.exports = validatorsRemote