aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
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