diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2015-11-07 18:40:13 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2015-11-07 18:40:13 +0100 |
commit | b60035d8e86b712e586550f762c26caae353dc0e (patch) | |
tree | a6dc088e5e48f93eb129e40672a7bea0d230a97c /routes/api/v1 | |
parent | e85782f7da44267e11714a63567feb7e0127126e (diff) | |
download | PeerTube-b60035d8e86b712e586550f762c26caae353dc0e.tar.gz PeerTube-b60035d8e86b712e586550f762c26caae353dc0e.tar.zst PeerTube-b60035d8e86b712e586550f762c26caae353dc0e.zip |
Middleware refractoring
Diffstat (limited to 'routes/api/v1')
-rw-r--r-- | routes/api/v1/pods.js | 9 | ||||
-rw-r--r-- | routes/api/v1/remoteVideos.js | 7 | ||||
-rw-r--r-- | routes/api/v1/videos.js | 13 |
3 files changed, 16 insertions, 13 deletions
diff --git a/routes/api/v1/pods.js b/routes/api/v1/pods.js index 8ae676834..2bb8f89ab 100644 --- a/routes/api/v1/pods.js +++ b/routes/api/v1/pods.js | |||
@@ -4,7 +4,8 @@ | |||
4 | var express = require('express') | 4 | var express = require('express') |
5 | var router = express.Router() | 5 | var router = express.Router() |
6 | var middleware = require('../../../middlewares') | 6 | var middleware = require('../../../middlewares') |
7 | var reqValidator = require('../../../middlewares/reqValidators').pods | 7 | var miscMiddleware = middleware.misc |
8 | var reqValidator = middleware.reqValidators.pods | ||
8 | var pods = require('../../../src/pods') | 9 | var pods = require('../../../src/pods') |
9 | 10 | ||
10 | function listPods (req, res, next) { | 11 | function listPods (req, res, next) { |
@@ -31,9 +32,9 @@ | |||
31 | }) | 32 | }) |
32 | } | 33 | } |
33 | 34 | ||
34 | router.get('/', middleware.cache(false), listPods) | 35 | router.get('/', miscMiddleware.cache(false), listPods) |
35 | router.get('/makefriends', middleware.cache(false), makeFriends) | 36 | router.get('/makefriends', miscMiddleware.cache(false), makeFriends) |
36 | router.post('/', reqValidator.podsAdd, middleware.cache(false), addPods) | 37 | router.post('/', reqValidator.podsAdd, miscMiddleware.cache(false), addPods) |
37 | 38 | ||
38 | module.exports = router | 39 | module.exports = router |
39 | })() | 40 | })() |
diff --git a/routes/api/v1/remoteVideos.js b/routes/api/v1/remoteVideos.js index 23bdcbe24..10793b2b4 100644 --- a/routes/api/v1/remoteVideos.js +++ b/routes/api/v1/remoteVideos.js | |||
@@ -4,7 +4,8 @@ | |||
4 | var express = require('express') | 4 | var express = require('express') |
5 | var router = express.Router() | 5 | var router = express.Router() |
6 | var middleware = require('../../../middlewares') | 6 | var middleware = require('../../../middlewares') |
7 | var requestValidator = require('../../../middlewares/reqValidators').remote | 7 | var miscMiddleware = middleware.misc |
8 | var reqValidator = middleware.reqValidators.remote | ||
8 | var videos = require('../../../src/videos') | 9 | var videos = require('../../../src/videos') |
9 | 10 | ||
10 | function addRemoteVideos (req, res, next) { | 11 | function addRemoteVideos (req, res, next) { |
@@ -23,8 +24,8 @@ | |||
23 | }) | 24 | }) |
24 | } | 25 | } |
25 | 26 | ||
26 | router.post('/add', requestValidator.secureRequest, middleware.decryptBody, requestValidator.remoteVideosAdd, middleware.cache(false), addRemoteVideos) | 27 | router.post('/add', reqValidator.secureRequest, miscMiddleware.decryptBody, reqValidator.remoteVideosAdd, miscMiddleware.cache(false), addRemoteVideos) |
27 | router.post('/remove', requestValidator.secureRequest, middleware.decryptBody, requestValidator.remoteVideosRemove, middleware.cache(false), removeRemoteVideo) | 28 | router.post('/remove', reqValidator.secureRequest, miscMiddleware.decryptBody, reqValidator.remoteVideosRemove, miscMiddleware.cache(false), removeRemoteVideo) |
28 | 29 | ||
29 | module.exports = router | 30 | module.exports = router |
30 | })() | 31 | })() |
diff --git a/routes/api/v1/videos.js b/routes/api/v1/videos.js index 06b248244..33c565437 100644 --- a/routes/api/v1/videos.js +++ b/routes/api/v1/videos.js | |||
@@ -4,7 +4,8 @@ | |||
4 | var express = require('express') | 4 | var express = require('express') |
5 | var router = express.Router() | 5 | var router = express.Router() |
6 | var middleware = require('../../../middlewares') | 6 | var middleware = require('../../../middlewares') |
7 | var reqValidator = require('../../../middlewares/reqValidators').videos | 7 | var miscMiddleware = middleware.misc |
8 | var reqValidator = middleware.reqValidators.videos | ||
8 | var videos = require('../../../src/videos') | 9 | var videos = require('../../../src/videos') |
9 | 10 | ||
10 | function listVideos (req, res, next) { | 11 | function listVideos (req, res, next) { |
@@ -52,11 +53,11 @@ | |||
52 | }) | 53 | }) |
53 | } | 54 | } |
54 | 55 | ||
55 | router.get('/', middleware.cache(false), listVideos) | 56 | router.get('/', miscMiddleware.cache(false), listVideos) |
56 | router.post('/', reqValidator.videosAdd, middleware.cache(false), addVideos) | 57 | router.post('/', reqValidator.videosAdd, miscMiddleware.cache(false), addVideos) |
57 | router.get('/search/:name', reqValidator.videosSearch, middleware.cache(false), searchVideos) | 58 | router.get('/search/:name', reqValidator.videosSearch, miscMiddleware.cache(false), searchVideos) |
58 | router.get('/:id', reqValidator.videosGet, middleware.cache(false), getVideos) | 59 | router.get('/:id', reqValidator.videosGet, miscMiddleware.cache(false), getVideos) |
59 | router.delete('/:id', reqValidator.videosRemove, middleware.cache(false), removeVideo) | 60 | router.delete('/:id', reqValidator.videosRemove, miscMiddleware.cache(false), removeVideo) |
60 | 61 | ||
61 | module.exports = router | 62 | module.exports = router |
62 | })() | 63 | })() |