aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/pagination.js
blob: 8e9a010536fb7cfd1f2a6d62e98c8e1c888f3845 (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 validatorsPagination = {
  pagination: pagination
}

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

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

  checkErrors(req, res, next)
}

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

module.exports = validatorsPagination