aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/reqValidators
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/reqValidators')
-rw-r--r--server/middlewares/reqValidators/index.js2
-rw-r--r--server/middlewares/reqValidators/pagination.js6
-rw-r--r--server/middlewares/reqValidators/sort.js23
3 files changed, 28 insertions, 3 deletions
diff --git a/server/middlewares/reqValidators/index.js b/server/middlewares/reqValidators/index.js
index b732a27b6..be68f6a29 100644
--- a/server/middlewares/reqValidators/index.js
+++ b/server/middlewares/reqValidators/index.js
@@ -3,12 +3,14 @@
3const paginationReqValidators = require('./pagination') 3const paginationReqValidators = require('./pagination')
4const podsReqValidators = require('./pods') 4const podsReqValidators = require('./pods')
5const remoteReqValidators = require('./remote') 5const remoteReqValidators = require('./remote')
6const sortReqValidators = require('./sort')
6const videosReqValidators = require('./videos') 7const videosReqValidators = require('./videos')
7 8
8const reqValidators = { 9const reqValidators = {
9 pagination: paginationReqValidators, 10 pagination: paginationReqValidators,
10 pods: podsReqValidators, 11 pods: podsReqValidators,
11 remote: remoteReqValidators, 12 remote: remoteReqValidators,
13 sort: sortReqValidators,
12 videos: videosReqValidators 14 videos: videosReqValidators
13} 15}
14 16
diff --git a/server/middlewares/reqValidators/pagination.js b/server/middlewares/reqValidators/pagination.js
index ca8375396..e598f269a 100644
--- a/server/middlewares/reqValidators/pagination.js
+++ b/server/middlewares/reqValidators/pagination.js
@@ -8,10 +8,10 @@ const reqValidatorsPagination = {
8} 8}
9 9
10function pagination (req, res, next) { 10function pagination (req, res, next) {
11 req.checkParams('start', 'Should have a number start').optional().isInt() 11 req.checkQuery('start', 'Should have a number start').optional().isInt()
12 req.checkParams('count', 'Should have a number count').optional().isInt() 12 req.checkQuery('count', 'Should have a number count').optional().isInt()
13 13
14 logger.debug('Checking pagination parameters', { parameters: req.params }) 14 logger.debug('Checking pagination parameters', { parameters: req.query })
15 15
16 checkErrors(req, res, next) 16 checkErrors(req, res, next)
17} 17}
diff --git a/server/middlewares/reqValidators/sort.js b/server/middlewares/reqValidators/sort.js
new file mode 100644
index 000000000..06e680ef4
--- /dev/null
+++ b/server/middlewares/reqValidators/sort.js
@@ -0,0 +1,23 @@
1'use strict'
2
3const checkErrors = require('./utils').checkErrors
4const constants = require('../../initializers/constants')
5const logger = require('../../helpers/logger')
6
7const reqValidatorsSort = {
8 videosSort: videosSort
9}
10
11function videosSort (req, res, next) {
12 const sortableColumns = constants.SORTABLE_COLUMNS.VIDEOS
13
14 req.checkQuery('sort', 'Should have correct sortable column').optional().isIn(sortableColumns)
15
16 logger.debug('Checking sort parameters', { parameters: req.query })
17
18 checkErrors(req, res, next)
19}
20
21// ---------------------------------------------------------------------------
22
23module.exports = reqValidatorsSort