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