PeerTube/server/middlewares/reqValidators/remote.js

44 lines
1.3 KiB
JavaScript
Raw Normal View History

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