diff options
-rw-r--r-- | server/controllers/api/v1/pods.js | 8 | ||||
-rw-r--r-- | server/controllers/api/v1/remote.js | 8 | ||||
-rw-r--r-- | server/controllers/api/v1/users.js | 1 | ||||
-rw-r--r-- | server/controllers/api/v1/videos.js | 24 | ||||
-rw-r--r-- | server/middlewares/index.js | 4 | ||||
-rw-r--r-- | server/middlewares/reqValidators/index.js | 19 | ||||
-rw-r--r-- | server/middlewares/validators/index.js | 19 | ||||
-rw-r--r-- | server/middlewares/validators/pagination.js (renamed from server/middlewares/reqValidators/pagination.js) | 4 | ||||
-rw-r--r-- | server/middlewares/validators/pods.js (renamed from server/middlewares/reqValidators/pods.js) | 4 | ||||
-rw-r--r-- | server/middlewares/validators/remote.js (renamed from server/middlewares/reqValidators/remote.js) | 4 | ||||
-rw-r--r-- | server/middlewares/validators/sort.js (renamed from server/middlewares/reqValidators/sort.js) | 4 | ||||
-rw-r--r-- | server/middlewares/validators/utils.js (renamed from server/middlewares/reqValidators/utils.js) | 4 | ||||
-rw-r--r-- | server/middlewares/validators/videos.js (renamed from server/middlewares/reqValidators/videos.js) | 4 |
13 files changed, 54 insertions, 53 deletions
diff --git a/server/controllers/api/v1/pods.js b/server/controllers/api/v1/pods.js index 9ce8120b2..4413fbc1e 100644 --- a/server/controllers/api/v1/pods.js +++ b/server/controllers/api/v1/pods.js | |||
@@ -8,16 +8,16 @@ const logger = require('../../../helpers/logger') | |||
8 | const friends = require('../../../lib/friends') | 8 | const friends = require('../../../lib/friends') |
9 | const middlewares = require('../../../middlewares') | 9 | const middlewares = require('../../../middlewares') |
10 | const oAuth = middlewares.oauth | 10 | const oAuth = middlewares.oauth |
11 | const reqValidator = middlewares.reqValidators.pods | 11 | const validators = middlewares.validators.pods |
12 | const signatureValidator = middlewares.reqValidators.remote.signature | 12 | const signatureValidator = middlewares.validators.remote.signature |
13 | 13 | ||
14 | const router = express.Router() | 14 | const router = express.Router() |
15 | const Pod = mongoose.model('Pod') | 15 | const Pod = mongoose.model('Pod') |
16 | const Video = mongoose.model('Video') | 16 | const Video = mongoose.model('Video') |
17 | 17 | ||
18 | router.get('/', listPodsUrl) | 18 | router.get('/', listPodsUrl) |
19 | router.post('/', reqValidator.podsAdd, addPods) | 19 | router.post('/', validators.podsAdd, addPods) |
20 | router.get('/makefriends', oAuth.authenticate, reqValidator.makeFriends, makeFriends) | 20 | router.get('/makefriends', oAuth.authenticate, validators.makeFriends, makeFriends) |
21 | router.get('/quitfriends', oAuth.authenticate, quitFriends) | 21 | router.get('/quitfriends', oAuth.authenticate, quitFriends) |
22 | // Post because this is a secured request | 22 | // Post because this is a secured request |
23 | router.post('/remove', signatureValidator, removePods) | 23 | router.post('/remove', signatureValidator, removePods) |
diff --git a/server/controllers/api/v1/remote.js b/server/controllers/api/v1/remote.js index 2d71c605d..7af9b7e84 100644 --- a/server/controllers/api/v1/remote.js +++ b/server/controllers/api/v1/remote.js | |||
@@ -6,17 +6,17 @@ const mongoose = require('mongoose') | |||
6 | 6 | ||
7 | const middlewares = require('../../../middlewares') | 7 | const middlewares = require('../../../middlewares') |
8 | const secureMiddleware = middlewares.secure | 8 | const secureMiddleware = middlewares.secure |
9 | const reqValidator = middlewares.reqValidators.remote | 9 | const validators = middlewares.validators.remote |
10 | const logger = require('../../../helpers/logger') | 10 | const logger = require('../../../helpers/logger') |
11 | 11 | ||
12 | const router = express.Router() | 12 | const router = express.Router() |
13 | const Video = mongoose.model('Video') | 13 | const Video = mongoose.model('Video') |
14 | 14 | ||
15 | router.post('/videos', | 15 | router.post('/videos', |
16 | reqValidator.signature, | 16 | validators.signature, |
17 | reqValidator.dataToDecrypt, | 17 | validators.dataToDecrypt, |
18 | secureMiddleware.decryptBody, | 18 | secureMiddleware.decryptBody, |
19 | reqValidator.remoteVideos, | 19 | validators.remoteVideos, |
20 | remoteVideos | 20 | remoteVideos |
21 | ) | 21 | ) |
22 | 22 | ||
diff --git a/server/controllers/api/v1/users.js b/server/controllers/api/v1/users.js index caa979567..dde459a73 100644 --- a/server/controllers/api/v1/users.js +++ b/server/controllers/api/v1/users.js | |||
@@ -3,6 +3,7 @@ | |||
3 | const config = require('config') | 3 | const config = require('config') |
4 | const mongoose = require('mongoose') | 4 | const mongoose = require('mongoose') |
5 | const express = require('express') | 5 | const express = require('express') |
6 | |||
6 | const oAuth = require('../../../middlewares').oauth | 7 | const oAuth = require('../../../middlewares').oauth |
7 | 8 | ||
8 | const Client = mongoose.model('OAuthClient') | 9 | const Client = mongoose.model('OAuthClient') |
diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js index ab115bc30..a37e9278e 100644 --- a/server/controllers/api/v1/videos.js +++ b/server/controllers/api/v1/videos.js | |||
@@ -11,10 +11,10 @@ const friends = require('../../../lib/friends') | |||
11 | const middlewares = require('../../../middlewares') | 11 | const middlewares = require('../../../middlewares') |
12 | const oAuth = middlewares.oauth | 12 | const oAuth = middlewares.oauth |
13 | const pagination = middlewares.pagination | 13 | const pagination = middlewares.pagination |
14 | const reqValidator = middlewares.reqValidators | 14 | const validators = middlewares.validators |
15 | const reqValidatorPagination = reqValidator.pagination | 15 | const validatorsPagination = validators.pagination |
16 | const reqValidatorSort = reqValidator.sort | 16 | const validatorsSort = validators.sort |
17 | const reqValidatorVideos = reqValidator.videos | 17 | const validatorsVideos = validators.videos |
18 | const search = middlewares.search | 18 | const search = middlewares.search |
19 | const sort = middlewares.sort | 19 | const sort = middlewares.sort |
20 | const utils = require('../../../helpers/utils') | 20 | const utils = require('../../../helpers/utils') |
@@ -44,8 +44,8 @@ const storage = multer.diskStorage({ | |||
44 | const reqFiles = multer({ storage: storage }).fields([{ name: 'videofile', maxCount: 1 }]) | 44 | const reqFiles = multer({ storage: storage }).fields([{ name: 'videofile', maxCount: 1 }]) |
45 | 45 | ||
46 | router.get('/', | 46 | router.get('/', |
47 | reqValidatorPagination.pagination, | 47 | validatorsPagination.pagination, |
48 | reqValidatorSort.videosSort, | 48 | validatorsSort.videosSort, |
49 | sort.setVideosSort, | 49 | sort.setVideosSort, |
50 | pagination.setPagination, | 50 | pagination.setPagination, |
51 | listVideos | 51 | listVideos |
@@ -53,22 +53,22 @@ router.get('/', | |||
53 | router.post('/', | 53 | router.post('/', |
54 | oAuth.authenticate, | 54 | oAuth.authenticate, |
55 | reqFiles, | 55 | reqFiles, |
56 | reqValidatorVideos.videosAdd, | 56 | validatorsVideos.videosAdd, |
57 | addVideo | 57 | addVideo |
58 | ) | 58 | ) |
59 | router.get('/:id', | 59 | router.get('/:id', |
60 | reqValidatorVideos.videosGet, | 60 | validatorsVideos.videosGet, |
61 | getVideo | 61 | getVideo |
62 | ) | 62 | ) |
63 | router.delete('/:id', | 63 | router.delete('/:id', |
64 | oAuth.authenticate, | 64 | oAuth.authenticate, |
65 | reqValidatorVideos.videosRemove, | 65 | validatorsVideos.videosRemove, |
66 | removeVideo | 66 | removeVideo |
67 | ) | 67 | ) |
68 | router.get('/search/:value', | 68 | router.get('/search/:value', |
69 | reqValidatorVideos.videosSearch, | 69 | validatorsVideos.videosSearch, |
70 | reqValidatorPagination.pagination, | 70 | validatorsPagination.pagination, |
71 | reqValidatorSort.videosSort, | 71 | validatorsSort.videosSort, |
72 | sort.setVideosSort, | 72 | sort.setVideosSort, |
73 | pagination.setPagination, | 73 | pagination.setPagination, |
74 | search.setVideosSearch, | 74 | search.setVideosSearch, |
diff --git a/server/middlewares/index.js b/server/middlewares/index.js index 01043cd85..0a233e701 100644 --- a/server/middlewares/index.js +++ b/server/middlewares/index.js | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | const oauth = require('./oauth') | 3 | const oauth = require('./oauth') |
4 | const pagination = require('./pagination') | 4 | const pagination = require('./pagination') |
5 | const reqValidatorsMiddleware = require('./reqValidators') | 5 | const validatorsMiddleware = require('./validators') |
6 | const search = require('./search') | 6 | const search = require('./search') |
7 | const sort = require('./sort') | 7 | const sort = require('./sort') |
8 | const secureMiddleware = require('./secure') | 8 | const secureMiddleware = require('./secure') |
@@ -10,7 +10,7 @@ const secureMiddleware = require('./secure') | |||
10 | const middlewares = { | 10 | const middlewares = { |
11 | oauth: oauth, | 11 | oauth: oauth, |
12 | pagination: pagination, | 12 | pagination: pagination, |
13 | reqValidators: reqValidatorsMiddleware, | 13 | validators: validatorsMiddleware, |
14 | search: search, | 14 | search: search, |
15 | sort: sort, | 15 | sort: sort, |
16 | secure: secureMiddleware | 16 | secure: secureMiddleware |
diff --git a/server/middlewares/reqValidators/index.js b/server/middlewares/reqValidators/index.js deleted file mode 100644 index be68f6a29..000000000 --- a/server/middlewares/reqValidators/index.js +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | const paginationReqValidators = require('./pagination') | ||
4 | const podsReqValidators = require('./pods') | ||
5 | const remoteReqValidators = require('./remote') | ||
6 | const sortReqValidators = require('./sort') | ||
7 | const videosReqValidators = require('./videos') | ||
8 | |||
9 | const reqValidators = { | ||
10 | pagination: paginationReqValidators, | ||
11 | pods: podsReqValidators, | ||
12 | remote: remoteReqValidators, | ||
13 | sort: sortReqValidators, | ||
14 | videos: videosReqValidators | ||
15 | } | ||
16 | |||
17 | // --------------------------------------------------------------------------- | ||
18 | |||
19 | module.exports = reqValidators | ||
diff --git a/server/middlewares/validators/index.js b/server/middlewares/validators/index.js new file mode 100644 index 000000000..0471b3f92 --- /dev/null +++ b/server/middlewares/validators/index.js | |||
@@ -0,0 +1,19 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | const paginationValidators = require('./pagination') | ||
4 | const podsValidators = require('./pods') | ||
5 | const remoteValidators = require('./remote') | ||
6 | const sortValidators = require('./sort') | ||
7 | const videosValidators = require('./videos') | ||
8 | |||
9 | const validators = { | ||
10 | pagination: paginationValidators, | ||
11 | pods: podsValidators, | ||
12 | remote: remoteValidators, | ||
13 | sort: sortValidators, | ||
14 | videos: videosValidators | ||
15 | } | ||
16 | |||
17 | // --------------------------------------------------------------------------- | ||
18 | |||
19 | module.exports = validators | ||
diff --git a/server/middlewares/reqValidators/pagination.js b/server/middlewares/validators/pagination.js index e598f269a..8e9a01053 100644 --- a/server/middlewares/reqValidators/pagination.js +++ b/server/middlewares/validators/pagination.js | |||
@@ -3,7 +3,7 @@ | |||
3 | const checkErrors = require('./utils').checkErrors | 3 | const checkErrors = require('./utils').checkErrors |
4 | const logger = require('../../helpers/logger') | 4 | const logger = require('../../helpers/logger') |
5 | 5 | ||
6 | const reqValidatorsPagination = { | 6 | const validatorsPagination = { |
7 | pagination: pagination | 7 | pagination: pagination |
8 | } | 8 | } |
9 | 9 | ||
@@ -18,4 +18,4 @@ function pagination (req, res, next) { | |||
18 | 18 | ||
19 | // --------------------------------------------------------------------------- | 19 | // --------------------------------------------------------------------------- |
20 | 20 | ||
21 | module.exports = reqValidatorsPagination | 21 | module.exports = validatorsPagination |
diff --git a/server/middlewares/reqValidators/pods.js b/server/middlewares/validators/pods.js index 78a4b76c1..fda2e865f 100644 --- a/server/middlewares/reqValidators/pods.js +++ b/server/middlewares/validators/pods.js | |||
@@ -4,7 +4,7 @@ const checkErrors = require('./utils').checkErrors | |||
4 | const friends = require('../../lib/friends') | 4 | const friends = require('../../lib/friends') |
5 | const logger = require('../../helpers/logger') | 5 | const logger = require('../../helpers/logger') |
6 | 6 | ||
7 | const reqValidatorsPod = { | 7 | const validatorsPod = { |
8 | makeFriends: makeFriends, | 8 | makeFriends: makeFriends, |
9 | podsAdd: podsAdd | 9 | podsAdd: podsAdd |
10 | } | 10 | } |
@@ -38,4 +38,4 @@ function podsAdd (req, res, next) { | |||
38 | 38 | ||
39 | // --------------------------------------------------------------------------- | 39 | // --------------------------------------------------------------------------- |
40 | 40 | ||
41 | module.exports = reqValidatorsPod | 41 | module.exports = validatorsPod |
diff --git a/server/middlewares/reqValidators/remote.js b/server/middlewares/validators/remote.js index dd8ee5f6e..1be119458 100644 --- a/server/middlewares/reqValidators/remote.js +++ b/server/middlewares/validators/remote.js | |||
@@ -3,7 +3,7 @@ | |||
3 | const checkErrors = require('./utils').checkErrors | 3 | const checkErrors = require('./utils').checkErrors |
4 | const logger = require('../../helpers/logger') | 4 | const logger = require('../../helpers/logger') |
5 | 5 | ||
6 | const reqValidatorsRemote = { | 6 | const validatorsRemote = { |
7 | dataToDecrypt: dataToDecrypt, | 7 | dataToDecrypt: dataToDecrypt, |
8 | remoteVideos: remoteVideos, | 8 | remoteVideos: remoteVideos, |
9 | signature: signature | 9 | signature: signature |
@@ -38,4 +38,4 @@ function signature (req, res, next) { | |||
38 | 38 | ||
39 | // --------------------------------------------------------------------------- | 39 | // --------------------------------------------------------------------------- |
40 | 40 | ||
41 | module.exports = reqValidatorsRemote | 41 | module.exports = validatorsRemote |
diff --git a/server/middlewares/reqValidators/sort.js b/server/middlewares/validators/sort.js index 06e680ef4..56b63cc8b 100644 --- a/server/middlewares/reqValidators/sort.js +++ b/server/middlewares/validators/sort.js | |||
@@ -4,7 +4,7 @@ const checkErrors = require('./utils').checkErrors | |||
4 | const constants = require('../../initializers/constants') | 4 | const constants = require('../../initializers/constants') |
5 | const logger = require('../../helpers/logger') | 5 | const logger = require('../../helpers/logger') |
6 | 6 | ||
7 | const reqValidatorsSort = { | 7 | const validatorsSort = { |
8 | videosSort: videosSort | 8 | videosSort: videosSort |
9 | } | 9 | } |
10 | 10 | ||
@@ -20,4 +20,4 @@ function videosSort (req, res, next) { | |||
20 | 20 | ||
21 | // --------------------------------------------------------------------------- | 21 | // --------------------------------------------------------------------------- |
22 | 22 | ||
23 | module.exports = reqValidatorsSort | 23 | module.exports = validatorsSort |
diff --git a/server/middlewares/reqValidators/utils.js b/server/middlewares/validators/utils.js index 198ed8d26..f6e5b2b38 100644 --- a/server/middlewares/reqValidators/utils.js +++ b/server/middlewares/validators/utils.js | |||
@@ -4,7 +4,7 @@ const util = require('util') | |||
4 | 4 | ||
5 | const logger = require('../../helpers/logger') | 5 | const logger = require('../../helpers/logger') |
6 | 6 | ||
7 | const reqValidatorsUtils = { | 7 | const validatorsUtils = { |
8 | checkErrors: checkErrors | 8 | checkErrors: checkErrors |
9 | } | 9 | } |
10 | 10 | ||
@@ -22,4 +22,4 @@ function checkErrors (req, res, next, statusCode) { | |||
22 | 22 | ||
23 | // --------------------------------------------------------------------------- | 23 | // --------------------------------------------------------------------------- |
24 | 24 | ||
25 | module.exports = reqValidatorsUtils | 25 | module.exports = validatorsUtils |
diff --git a/server/middlewares/reqValidators/videos.js b/server/middlewares/validators/videos.js index 452fbc859..24e2299dc 100644 --- a/server/middlewares/reqValidators/videos.js +++ b/server/middlewares/validators/videos.js | |||
@@ -9,7 +9,7 @@ const logger = require('../../helpers/logger') | |||
9 | 9 | ||
10 | const Video = mongoose.model('Video') | 10 | const Video = mongoose.model('Video') |
11 | 11 | ||
12 | const reqValidatorsVideos = { | 12 | const validatorsVideos = { |
13 | videosAdd: videosAdd, | 13 | videosAdd: videosAdd, |
14 | videosGet: videosGet, | 14 | videosGet: videosGet, |
15 | videosRemove: videosRemove, | 15 | videosRemove: videosRemove, |
@@ -94,4 +94,4 @@ function videosSearch (req, res, next) { | |||
94 | 94 | ||
95 | // --------------------------------------------------------------------------- | 95 | // --------------------------------------------------------------------------- |
96 | 96 | ||
97 | module.exports = reqValidatorsVideos | 97 | module.exports = validatorsVideos |