aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-24 16:27:45 +0200
committerChocobozzz <me@florianbigard.com>2018-07-24 18:03:38 +0200
commit1194e8b46f53204967271f1c6bfb7428a717a483 (patch)
tree2a89501df534747db4d261f39a6d279ac0e8fba9 /server/middlewares
parent76dd3e89ae4f0f4a6652083f653a49acc97797fc (diff)
downloadPeerTube-1194e8b46f53204967271f1c6bfb7428a717a483.tar.gz
PeerTube-1194e8b46f53204967271f1c6bfb7428a717a483.tar.zst
PeerTube-1194e8b46f53204967271f1c6bfb7428a717a483.zip
Add max count in pagination
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/pagination.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/server/middlewares/pagination.ts b/server/middlewares/pagination.ts
index 2ea2a6b82..9b497b19e 100644
--- a/server/middlewares/pagination.ts
+++ b/server/middlewares/pagination.ts
@@ -1,15 +1,17 @@
1import 'express-validator' 1import 'express-validator'
2import * as express from 'express' 2import * as express from 'express'
3 3
4import { PAGINATION_COUNT_DEFAULT } from '../initializers' 4import { PAGINATION } from '../initializers'
5 5
6function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) { 6function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) {
7 if (!req.query.start) req.query.start = 0 7 if (!req.query.start) req.query.start = 0
8 else req.query.start = parseInt(req.query.start, 10) 8 else req.query.start = parseInt(req.query.start, 10)
9 9
10 if (!req.query.count) req.query.count = PAGINATION_COUNT_DEFAULT 10 if (!req.query.count) req.query.count = PAGINATION.COUNT.DEFAULT
11 else req.query.count = parseInt(req.query.count, 10) 11 else req.query.count = parseInt(req.query.count, 10)
12 12
13 if (req.query.count > PAGINATION.COUNT.MAX) req.query.count = PAGINATION.COUNT.MAX
14
13 return next() 15 return next()
14} 16}
15 17