aboutsummaryrefslogtreecommitdiffhomepage
path: root/middlewares/reqValidators/remote.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2015-11-07 14:16:26 +0100
committerChocobozzz <florian.bigard@gmail.com>2015-11-07 14:16:26 +0100
commit34ca3b5225479a5da986c86ee4c42a73ae6df5ad (patch)
tree561ba5ae1adccd5729305a8cc17d13d24a0c2ddb /middlewares/reqValidators/remote.js
parentf5a60a5138135a3412dfbcfd6e564f7aa47a55c2 (diff)
downloadPeerTube-34ca3b5225479a5da986c86ee4c42a73ae6df5ad.tar.gz
PeerTube-34ca3b5225479a5da986c86ee4c42a73ae6df5ad.tar.zst
PeerTube-34ca3b5225479a5da986c86ee4c42a73ae6df5ad.zip
Add requests parameters validations
Diffstat (limited to 'middlewares/reqValidators/remote.js')
-rw-r--r--middlewares/reqValidators/remote.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/middlewares/reqValidators/remote.js b/middlewares/reqValidators/remote.js
new file mode 100644
index 000000000..e851b49a4
--- /dev/null
+++ b/middlewares/reqValidators/remote.js
@@ -0,0 +1,40 @@
1;(function () {
2 'use strict'
3
4 var checkErrors = require('./utils').checkErrors
5 var logger = require('../../src/logger')
6
7 var remote = {}
8
9 remote.secureRequest = function (req, res, next) {
10 req.checkBody('signature.url', 'Should have a signature url').isURL()
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: req.body })
16
17 checkErrors(req, res, next)
18 }
19
20 remote.remoteVideosAdd = function (req, res, next) {
21 req.checkBody('data.name', 'Should have a name').isLength(1, 50)
22 req.checkBody('data.description', 'Should have a description').isLength(1, 250)
23 req.checkBody('data.magnetUri', 'Should have a magnetUri').notEmpty()
24 req.checkBody('data.podUrl', 'Should have a podUrl').isURL()
25
26 logger.debug('Checking remoteVideosAdd parameters', { parameters: req.body })
27
28 checkErrors(req, res, next)
29 }
30
31 remote.remoteVideosRemove = function (req, res, next) {
32 req.checkBody('data.magnetUri', 'Should have a magnetUri').notEmpty()
33
34 logger.debug('Checking remoteVideosRemove parameters', { parameters: req.body })
35
36 checkErrors(req, res, next)
37 }
38
39 module.exports = remote
40})()