aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/middlewares/validators/pagination.ts
blob: cca8295ffddc731bc309c3e189fb58210b9fffb0 (plain) (tree)
1
2
3
4
5
6
7
8
9


                                  

                                      
 
                                                                                                        

                                                                          
 
                                                                           





                                                                              


                     
import 'express-validator'
import * as express from 'express'

import { checkErrors } from './utils'
import { logger } from '../../helpers'

function paginationValidator (req: express.Request, res: express.Response, next: express.NextFunction) {
  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)
}

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

export {
  paginationValidator
}