2016-05-13 11:10:46 -05:00
|
|
|
'use strict'
|
|
|
|
|
2016-05-13 13:10:02 -05:00
|
|
|
const constants = require('../initializers/constants')
|
|
|
|
|
2016-05-13 11:10:46 -05:00
|
|
|
const paginationMiddleware = {
|
|
|
|
setPagination: setPagination
|
|
|
|
}
|
|
|
|
|
|
|
|
function setPagination (req, res, next) {
|
|
|
|
if (!req.query.start) req.query.start = 0
|
|
|
|
else req.query.start = parseInt(req.query.start)
|
2016-05-13 13:10:02 -05:00
|
|
|
if (!req.query.count) req.query.count = constants.PAGINATION_COUNT_DEFAULT
|
2016-05-13 11:10:46 -05:00
|
|
|
else req.query.count = parseInt(req.query.count)
|
|
|
|
|
|
|
|
return next()
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
module.exports = paginationMiddleware
|