2016-05-13 18:10:46 +02:00
|
|
|
'use strict'
|
|
|
|
|
2016-05-13 20:10:02 +02:00
|
|
|
const constants = require('../initializers/constants')
|
|
|
|
|
2016-05-13 18:10:46 +02: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 20:10:02 +02:00
|
|
|
if (!req.query.count) req.query.count = constants.PAGINATION_COUNT_DEFAULT
|
2016-05-13 18:10:46 +02:00
|
|
|
else req.query.count = parseInt(req.query.count)
|
|
|
|
|
|
|
|
return next()
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
module.exports = paginationMiddleware
|