aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/pagination.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/pagination.ts')
-rw-r--r--server/middlewares/pagination.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/server/middlewares/pagination.ts b/server/middlewares/pagination.ts
new file mode 100644
index 000000000..8fe9f9082
--- /dev/null
+++ b/server/middlewares/pagination.ts
@@ -0,0 +1,17 @@
1const constants = require('../initializers/constants')
2
3function setPagination (req, res, next) {
4 if (!req.query.start) req.query.start = 0
5 else req.query.start = parseInt(req.query.start, 10)
6
7 if (!req.query.count) req.query.count = constants.PAGINATION_COUNT_DEFAULT
8 else req.query.count = parseInt(req.query.count, 10)
9
10 return next()
11}
12
13// ---------------------------------------------------------------------------
14
15export {
16 setPagination
17}