From a5fa04b0cce851f680a45055f57ed2c3d22f1c82 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 4 Feb 2016 21:16:27 +0100 Subject: Split misc middleware --- controllers/api/v1/pods.js | 13 +++++++------ controllers/api/v1/remoteVideos.js | 11 ++++++----- controllers/api/v1/videos.js | 12 ++++++------ 3 files changed, 19 insertions(+), 17 deletions(-) (limited to 'controllers/api/v1') diff --git a/controllers/api/v1/pods.js b/controllers/api/v1/pods.js index 82d8d7f08..3e457ec57 100644 --- a/controllers/api/v1/pods.js +++ b/controllers/api/v1/pods.js @@ -7,21 +7,22 @@ var logger = require('../../../helpers/logger') var friends = require('../../../lib/friends') var middleware = require('../../../middlewares') - var miscMiddleware = middleware.misc + var cacheMiddleware = middleware.cache var Pods = require('../../../models/pods') var reqValidator = middleware.reqValidators.pods + var secureMiddleware = middleware.secure var secureRequest = middleware.reqValidators.remote.secureRequest var utils = require('../../../helpers/utils') var Videos = require('../../../models/videos') var router = express.Router() - router.get('/', miscMiddleware.cache(false), listPods) - router.post('/', reqValidator.podsAdd, miscMiddleware.cache(false), addPods) - router.get('/makefriends', reqValidator.makeFriends, miscMiddleware.cache(false), makeFriends) - router.get('/quitfriends', miscMiddleware.cache(false), quitFriends) + router.get('/', cacheMiddleware.cache(false), listPods) + router.post('/', reqValidator.podsAdd, cacheMiddleware.cache(false), addPods) + router.get('/makefriends', reqValidator.makeFriends, cacheMiddleware.cache(false), makeFriends) + router.get('/quitfriends', cacheMiddleware.cache(false), quitFriends) // Post because this is a secured request - router.post('/remove', secureRequest, miscMiddleware.decryptBody, removePods) + router.post('/remove', secureRequest, secureMiddleware.decryptBody, removePods) // --------------------------------------------------------------------------- diff --git a/controllers/api/v1/remoteVideos.js b/controllers/api/v1/remoteVideos.js index d72db9836..58bb5f3cb 100644 --- a/controllers/api/v1/remoteVideos.js +++ b/controllers/api/v1/remoteVideos.js @@ -5,7 +5,8 @@ var pluck = require('lodash-node/compat/collection/pluck') var middleware = require('../../../middlewares') - var miscMiddleware = middleware.misc + var secureMiddleware = middleware.secure + var cacheMiddleware = middleware.cache var reqValidator = middleware.reqValidators.remote var videos = require('../../../models/videos') @@ -13,17 +14,17 @@ router.post('/add', reqValidator.secureRequest, - miscMiddleware.decryptBody, + secureMiddleware.decryptBody, reqValidator.remoteVideosAdd, - miscMiddleware.cache(false), + cacheMiddleware.cache(false), addRemoteVideos ) router.post('/remove', reqValidator.secureRequest, - miscMiddleware.decryptBody, + secureMiddleware.decryptBody, reqValidator.remoteVideosRemove, - miscMiddleware.cache(false), + cacheMiddleware.cache(false), removeRemoteVideo ) diff --git a/controllers/api/v1/videos.js b/controllers/api/v1/videos.js index d2e7e8825..7792059ca 100644 --- a/controllers/api/v1/videos.js +++ b/controllers/api/v1/videos.js @@ -9,7 +9,7 @@ var logger = require('../../../helpers/logger') var friends = require('../../../lib/friends') var middleware = require('../../../middlewares') - var miscMiddleware = middleware.misc + var cacheMiddleware = middleware.cache var reqValidator = middleware.reqValidators.videos var Videos = require('../../../models/videos') // model var videos = require('../../../lib/videos') @@ -38,11 +38,11 @@ var reqFiles = multer({ storage: storage }).fields([{ name: 'input_video', maxCount: 1 }]) - router.get('/', miscMiddleware.cache(false), listVideos) - router.post('/', reqFiles, reqValidator.videosAdd, miscMiddleware.cache(false), addVideo) - router.get('/:id', reqValidator.videosGet, miscMiddleware.cache(false), getVideos) - router.delete('/:id', reqValidator.videosRemove, miscMiddleware.cache(false), removeVideo) - router.get('/search/:name', reqValidator.videosSearch, miscMiddleware.cache(false), searchVideos) + router.get('/', cacheMiddleware.cache(false), listVideos) + router.post('/', reqFiles, reqValidator.videosAdd, cacheMiddleware.cache(false), addVideo) + router.get('/:id', reqValidator.videosGet, cacheMiddleware.cache(false), getVideos) + router.delete('/:id', reqValidator.videosRemove, cacheMiddleware.cache(false), removeVideo) + router.get('/search/:name', reqValidator.videosSearch, cacheMiddleware.cache(false), searchVideos) // --------------------------------------------------------------------------- -- cgit v1.2.3