2021-08-27 07:32:44 -05:00
|
|
|
import express from 'express'
|
2023-07-31 07:34:36 -05:00
|
|
|
import { forceNumber } from '@peertube/peertube-core-utils'
|
|
|
|
import { PAGINATION } from '../initializers/constants.js'
|
2016-05-13 13:10:02 -05:00
|
|
|
|
2018-01-18 03:53:54 -06:00
|
|
|
function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) {
|
2016-05-13 11:10:46 -05:00
|
|
|
if (!req.query.start) req.query.start = 0
|
2022-11-15 07:41:55 -06:00
|
|
|
else req.query.start = forceNumber(req.query.start)
|
2017-05-15 15:22:03 -05:00
|
|
|
|
2020-01-09 02:36:31 -06:00
|
|
|
if (!req.query.count) req.query.count = PAGINATION.GLOBAL.COUNT.DEFAULT
|
2022-11-15 07:41:55 -06:00
|
|
|
else req.query.count = forceNumber(req.query.count)
|
2016-05-13 11:10:46 -05:00
|
|
|
|
|
|
|
return next()
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2017-05-15 15:22:03 -05:00
|
|
|
export {
|
2018-01-18 03:53:54 -06:00
|
|
|
setDefaultPagination
|
2017-05-15 15:22:03 -05:00
|
|
|
}
|