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.js21
2 files changed, 23 insertions, 0 deletions
diff --git a/server/middlewares/reqValidators/index.js b/server/middlewares/reqValidators/index.js
index c6c5e1309..b732a27b6 100644
--- a/server/middlewares/reqValidators/index.js
+++ b/server/middlewares/reqValidators/index.js
@@ -1,10 +1,12 @@
1'use strict' 1'use strict'
2 2
3const paginationReqValidators = require('./pagination')
3const podsReqValidators = require('./pods') 4const podsReqValidators = require('./pods')
4const remoteReqValidators = require('./remote') 5const remoteReqValidators = require('./remote')
5const videosReqValidators = require('./videos') 6const videosReqValidators = require('./videos')
6 7
7const reqValidators = { 8const reqValidators = {
9 pagination: paginationReqValidators,
8 pods: podsReqValidators, 10 pods: podsReqValidators,
9 remote: remoteReqValidators, 11 remote: remoteReqValidators,
10 videos: videosReqValidators 12 videos: videosReqValidators
diff --git a/server/middlewares/reqValidators/pagination.js b/server/middlewares/reqValidators/pagination.js
new file mode 100644
index 000000000..ca8375396
--- /dev/null
+++ b/server/middlewares/reqValidators/pagination.js
@@ -0,0 +1,21 @@
1'use strict'
2
3const checkErrors = require('./utils').checkErrors
4const logger = require('../../helpers/logger')
5
6const reqValidatorsPagination = {
7 pagination: pagination
8}
9
10function pagination (req, res, next) {
11 req.checkParams('start', 'Should have a number start').optional().isInt()
12 req.checkParams('count', 'Should have a number count').optional().isInt()
13
14 logger.debug('Checking pagination parameters', { parameters: req.params })
15
16 checkErrors(req, res, next)
17}
18
19// ---------------------------------------------------------------------------
20
21module.exports = reqValidatorsPagination