aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/reqValidators/pagination.js
blob: ca8375396f4f1c4aa43a9d90d9b7befa85f42214 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict'

const checkErrors = require('./utils').checkErrors
const logger = require('../../helpers/logger')

const reqValidatorsPagination = {
  pagination: pagination
}

function pagination (req, res, next) {
  req.checkParams('start', 'Should have a number start').optional().isInt()
  req.checkParams('count', 'Should have a number count').optional().isInt()

  logger.debug('Checking pagination parameters', { parameters: req.params })

  checkErrors(req, res, next)
}

// ---------------------------------------------------------------------------

module.exports = reqValidatorsPagination