From b9a3e09ad5a7673f64556d1dba122ed4c4fac980 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 7 Mar 2016 11:33:59 +0100 Subject: Prepare folders structure for angular app --- server/middlewares/reqValidators/remote.js | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 server/middlewares/reqValidators/remote.js (limited to 'server/middlewares/reqValidators/remote.js') 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 @@ +'use strict' + +var checkErrors = require('./utils').checkErrors +var logger = require('../../helpers/logger') + +var reqValidatorsRemote = { + remoteVideosAdd: remoteVideosAdd, + remoteVideosRemove: remoteVideosRemove, + secureRequest: secureRequest +} + +function remoteVideosAdd (req, res, next) { + req.checkBody('data').isArray() + req.checkBody('data').eachIsRemoteVideosAddValid() + + logger.debug('Checking remoteVideosAdd parameters', { parameters: req.body }) + + checkErrors(req, res, next) +} + +function remoteVideosRemove (req, res, next) { + req.checkBody('data').isArray() + req.checkBody('data').eachIsRemoteVideosRemoveValid() + + logger.debug('Checking remoteVideosRemove parameters', { parameters: req.body }) + + checkErrors(req, res, next) +} + +function secureRequest (req, res, next) { + req.checkBody('signature.url', 'Should have a signature url').isURL() + req.checkBody('signature.signature', 'Should have a signature').notEmpty() + req.checkBody('key', 'Should have a key').notEmpty() + req.checkBody('data', 'Should have data').notEmpty() + + logger.debug('Checking secureRequest parameters', { parameters: { data: req.body.data, keyLength: req.body.key.length } }) + + checkErrors(req, res, next) +} + +// --------------------------------------------------------------------------- + +module.exports = reqValidatorsRemote -- cgit v1.2.3