mirror of https://github.com/Chocobozzz/PeerTube
reqValidators --> validators
parent
69b0a27cbb
commit
fc51fde048
|
@ -8,16 +8,16 @@ const logger = require('../../../helpers/logger')
|
|||
const friends = require('../../../lib/friends')
|
||||
const middlewares = require('../../../middlewares')
|
||||
const oAuth = middlewares.oauth
|
||||
const reqValidator = middlewares.reqValidators.pods
|
||||
const signatureValidator = middlewares.reqValidators.remote.signature
|
||||
const validators = middlewares.validators.pods
|
||||
const signatureValidator = middlewares.validators.remote.signature
|
||||
|
||||
const router = express.Router()
|
||||
const Pod = mongoose.model('Pod')
|
||||
const Video = mongoose.model('Video')
|
||||
|
||||
router.get('/', listPodsUrl)
|
||||
router.post('/', reqValidator.podsAdd, addPods)
|
||||
router.get('/makefriends', oAuth.authenticate, reqValidator.makeFriends, makeFriends)
|
||||
router.post('/', validators.podsAdd, addPods)
|
||||
router.get('/makefriends', oAuth.authenticate, validators.makeFriends, makeFriends)
|
||||
router.get('/quitfriends', oAuth.authenticate, quitFriends)
|
||||
// Post because this is a secured request
|
||||
router.post('/remove', signatureValidator, removePods)
|
||||
|
|
|
@ -6,17 +6,17 @@ const mongoose = require('mongoose')
|
|||
|
||||
const middlewares = require('../../../middlewares')
|
||||
const secureMiddleware = middlewares.secure
|
||||
const reqValidator = middlewares.reqValidators.remote
|
||||
const validators = middlewares.validators.remote
|
||||
const logger = require('../../../helpers/logger')
|
||||
|
||||
const router = express.Router()
|
||||
const Video = mongoose.model('Video')
|
||||
|
||||
router.post('/videos',
|
||||
reqValidator.signature,
|
||||
reqValidator.dataToDecrypt,
|
||||
validators.signature,
|
||||
validators.dataToDecrypt,
|
||||
secureMiddleware.decryptBody,
|
||||
reqValidator.remoteVideos,
|
||||
validators.remoteVideos,
|
||||
remoteVideos
|
||||
)
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
const config = require('config')
|
||||
const mongoose = require('mongoose')
|
||||
const express = require('express')
|
||||
|
||||
const oAuth = require('../../../middlewares').oauth
|
||||
|
||||
const Client = mongoose.model('OAuthClient')
|
||||
|
|
|
@ -11,10 +11,10 @@ const friends = require('../../../lib/friends')
|
|||
const middlewares = require('../../../middlewares')
|
||||
const oAuth = middlewares.oauth
|
||||
const pagination = middlewares.pagination
|
||||
const reqValidator = middlewares.reqValidators
|
||||
const reqValidatorPagination = reqValidator.pagination
|
||||
const reqValidatorSort = reqValidator.sort
|
||||
const reqValidatorVideos = reqValidator.videos
|
||||
const validators = middlewares.validators
|
||||
const validatorsPagination = validators.pagination
|
||||
const validatorsSort = validators.sort
|
||||
const validatorsVideos = validators.videos
|
||||
const search = middlewares.search
|
||||
const sort = middlewares.sort
|
||||
const utils = require('../../../helpers/utils')
|
||||
|
@ -44,8 +44,8 @@ const storage = multer.diskStorage({
|
|||
const reqFiles = multer({ storage: storage }).fields([{ name: 'videofile', maxCount: 1 }])
|
||||
|
||||
router.get('/',
|
||||
reqValidatorPagination.pagination,
|
||||
reqValidatorSort.videosSort,
|
||||
validatorsPagination.pagination,
|
||||
validatorsSort.videosSort,
|
||||
sort.setVideosSort,
|
||||
pagination.setPagination,
|
||||
listVideos
|
||||
|
@ -53,22 +53,22 @@ router.get('/',
|
|||
router.post('/',
|
||||
oAuth.authenticate,
|
||||
reqFiles,
|
||||
reqValidatorVideos.videosAdd,
|
||||
validatorsVideos.videosAdd,
|
||||
addVideo
|
||||
)
|
||||
router.get('/:id',
|
||||
reqValidatorVideos.videosGet,
|
||||
validatorsVideos.videosGet,
|
||||
getVideo
|
||||
)
|
||||
router.delete('/:id',
|
||||
oAuth.authenticate,
|
||||
reqValidatorVideos.videosRemove,
|
||||
validatorsVideos.videosRemove,
|
||||
removeVideo
|
||||
)
|
||||
router.get('/search/:value',
|
||||
reqValidatorVideos.videosSearch,
|
||||
reqValidatorPagination.pagination,
|
||||
reqValidatorSort.videosSort,
|
||||
validatorsVideos.videosSearch,
|
||||
validatorsPagination.pagination,
|
||||
validatorsSort.videosSort,
|
||||
sort.setVideosSort,
|
||||
pagination.setPagination,
|
||||
search.setVideosSearch,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const oauth = require('./oauth')
|
||||
const pagination = require('./pagination')
|
||||
const reqValidatorsMiddleware = require('./reqValidators')
|
||||
const validatorsMiddleware = require('./validators')
|
||||
const search = require('./search')
|
||||
const sort = require('./sort')
|
||||
const secureMiddleware = require('./secure')
|
||||
|
@ -10,7 +10,7 @@ const secureMiddleware = require('./secure')
|
|||
const middlewares = {
|
||||
oauth: oauth,
|
||||
pagination: pagination,
|
||||
reqValidators: reqValidatorsMiddleware,
|
||||
validators: validatorsMiddleware,
|
||||
search: search,
|
||||
sort: sort,
|
||||
secure: secureMiddleware
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
'use strict'
|
||||
|
||||
const paginationReqValidators = require('./pagination')
|
||||
const podsReqValidators = require('./pods')
|
||||
const remoteReqValidators = require('./remote')
|
||||
const sortReqValidators = require('./sort')
|
||||
const videosReqValidators = require('./videos')
|
||||
|
||||
const reqValidators = {
|
||||
pagination: paginationReqValidators,
|
||||
pods: podsReqValidators,
|
||||
remote: remoteReqValidators,
|
||||
sort: sortReqValidators,
|
||||
videos: videosReqValidators
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
module.exports = reqValidators
|
|
@ -0,0 +1,19 @@
|
|||
'use strict'
|
||||
|
||||
const paginationValidators = require('./pagination')
|
||||
const podsValidators = require('./pods')
|
||||
const remoteValidators = require('./remote')
|
||||
const sortValidators = require('./sort')
|
||||
const videosValidators = require('./videos')
|
||||
|
||||
const validators = {
|
||||
pagination: paginationValidators,
|
||||
pods: podsValidators,
|
||||
remote: remoteValidators,
|
||||
sort: sortValidators,
|
||||
videos: videosValidators
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
module.exports = validators
|
|
@ -3,7 +3,7 @@
|
|||
const checkErrors = require('./utils').checkErrors
|
||||
const logger = require('../../helpers/logger')
|
||||
|
||||
const reqValidatorsPagination = {
|
||||
const validatorsPagination = {
|
||||
pagination: pagination
|
||||
}
|
||||
|
||||
|
@ -18,4 +18,4 @@ function pagination (req, res, next) {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
module.exports = reqValidatorsPagination
|
||||
module.exports = validatorsPagination
|
|
@ -4,7 +4,7 @@ const checkErrors = require('./utils').checkErrors
|
|||
const friends = require('../../lib/friends')
|
||||
const logger = require('../../helpers/logger')
|
||||
|
||||
const reqValidatorsPod = {
|
||||
const validatorsPod = {
|
||||
makeFriends: makeFriends,
|
||||
podsAdd: podsAdd
|
||||
}
|
||||
|
@ -38,4 +38,4 @@ function podsAdd (req, res, next) {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
module.exports = reqValidatorsPod
|
||||
module.exports = validatorsPod
|
|
@ -3,7 +3,7 @@
|
|||
const checkErrors = require('./utils').checkErrors
|
||||
const logger = require('../../helpers/logger')
|
||||
|
||||
const reqValidatorsRemote = {
|
||||
const validatorsRemote = {
|
||||
dataToDecrypt: dataToDecrypt,
|
||||
remoteVideos: remoteVideos,
|
||||
signature: signature
|
||||
|
@ -38,4 +38,4 @@ function signature (req, res, next) {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
module.exports = reqValidatorsRemote
|
||||
module.exports = validatorsRemote
|
|
@ -4,7 +4,7 @@ const checkErrors = require('./utils').checkErrors
|
|||
const constants = require('../../initializers/constants')
|
||||
const logger = require('../../helpers/logger')
|
||||
|
||||
const reqValidatorsSort = {
|
||||
const validatorsSort = {
|
||||
videosSort: videosSort
|
||||
}
|
||||
|
||||
|
@ -20,4 +20,4 @@ function videosSort (req, res, next) {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
module.exports = reqValidatorsSort
|
||||
module.exports = validatorsSort
|
|
@ -4,7 +4,7 @@ const util = require('util')
|
|||
|
||||
const logger = require('../../helpers/logger')
|
||||
|
||||
const reqValidatorsUtils = {
|
||||
const validatorsUtils = {
|
||||
checkErrors: checkErrors
|
||||
}
|
||||
|
||||
|
@ -22,4 +22,4 @@ function checkErrors (req, res, next, statusCode) {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
module.exports = reqValidatorsUtils
|
||||
module.exports = validatorsUtils
|
|
@ -9,7 +9,7 @@ const logger = require('../../helpers/logger')
|
|||
|
||||
const Video = mongoose.model('Video')
|
||||
|
||||
const reqValidatorsVideos = {
|
||||
const validatorsVideos = {
|
||||
videosAdd: videosAdd,
|
||||
videosGet: videosGet,
|
||||
videosRemove: videosRemove,
|
||||
|
@ -94,4 +94,4 @@ function videosSearch (req, res, next) {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
module.exports = reqValidatorsVideos
|
||||
module.exports = validatorsVideos
|
Loading…
Reference in New Issue