// API version
const API_VERSION = 'v1'
-// Number of results by default for the pagination
-const PAGINATION_COUNT_DEFAULT = 15
+const PAGINATION = {
+ COUNT: {
+ DEFAULT: 15,
+ MAX: 100
+ }
+}
// Sortable columns per schema
const SORTABLE_COLUMNS = {
OAUTH_LIFETIME,
CUSTOM_HTML_TAG_COMMENTS,
BROADCAST_CONCURRENCY,
- PAGINATION_COUNT_DEFAULT,
+ PAGINATION,
ACTOR_FOLLOW_SCORE,
PREVIEWS_SIZE,
REMOTE_SCHEME,
import 'express-validator'
import * as express from 'express'
-import { PAGINATION_COUNT_DEFAULT } from '../initializers'
+import { PAGINATION } from '../initializers'
function setDefaultPagination (req: express.Request, res: express.Response, next: express.NextFunction) {
if (!req.query.start) req.query.start = 0
else req.query.start = parseInt(req.query.start, 10)
- if (!req.query.count) req.query.count = PAGINATION_COUNT_DEFAULT
+ if (!req.query.count) req.query.count = PAGINATION.COUNT.DEFAULT
else req.query.count = parseInt(req.query.count, 10)
+ if (req.query.count > PAGINATION.COUNT.MAX) req.query.count = PAGINATION.COUNT.MAX
+
return next()
}