pagination.ts 616 B

12345678910111213141516171819
  1. import express from 'express'
  2. import { forceNumber } from '@peertube/peertube-core-utils'
  3. import { PAGINATION } from '../initializers/constants.js'
  4. function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) {
  5. if (!req.query.start) req.query.start = 0
  6. else req.query.start = forceNumber(req.query.start)
  7. if (!req.query.count) req.query.count = PAGINATION.GLOBAL.COUNT.DEFAULT
  8. else req.query.count = forceNumber(req.query.count)
  9. return next()
  10. }
  11. // ---------------------------------------------------------------------------
  12. export {
  13. setDefaultPagination
  14. }