diff options
Diffstat (limited to 'server/middlewares/pagination.ts')
-rw-r--r-- | server/middlewares/pagination.ts | 17 |
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 @@ | |||
1 | const constants = require('../initializers/constants') | ||
2 | |||
3 | function 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 | |||
15 | export { | ||
16 | setPagination | ||
17 | } | ||