1
0
Fork 0
peertube/server/middlewares/reqValidators/remote.js

44 lines
1.3 KiB
JavaScript
Raw Normal View History

'use strict'
2015-11-07 13:16:26 +00:00
var checkErrors = require('./utils').checkErrors
var logger = require('../../helpers/logger')
2015-11-07 13:16:26 +00:00
var reqValidatorsRemote = {
remoteVideosAdd: remoteVideosAdd,
remoteVideosRemove: remoteVideosRemove,
secureRequest: secureRequest
}
2015-11-07 13:16:26 +00:00
function remoteVideosAdd (req, res, next) {
req.checkBody('data').isArray()
req.checkBody('data').eachIsRemoteVideosAddValid()
2015-11-07 13:16:26 +00:00
logger.debug('Checking remoteVideosAdd parameters', { parameters: req.body })
2015-11-07 13:16:26 +00:00
checkErrors(req, res, next)
}
2015-11-07 13:16:26 +00:00
function remoteVideosRemove (req, res, next) {
req.checkBody('data').isArray()
req.checkBody('data').eachIsRemoteVideosRemoveValid()
2015-11-07 13:16:26 +00:00
logger.debug('Checking remoteVideosRemove parameters', { parameters: req.body })
2015-11-07 13:16:26 +00:00
checkErrors(req, res, next)
}
2015-11-07 13:16:26 +00:00
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()
2016-01-31 10:23:52 +00:00
logger.debug('Checking secureRequest parameters', { parameters: { data: req.body.data, keyLength: req.body.key.length } })
2016-01-31 10:23:52 +00:00
checkErrors(req, res, next)
}
2016-01-31 10:23:52 +00:00
// ---------------------------------------------------------------------------
2016-01-31 10:23:52 +00:00
module.exports = reqValidatorsRemote