Mandatory pagination for GET /challenges/user (#12792)

* BREAKING: require pagination for GET /challenges/user

* fix tests

* remove unused test
This commit is contained in:
Matteo Pagliazzi
2020-11-19 23:18:11 +01:00
committed by GitHub
parent c19c39d72d
commit 284cfde935
2 changed files with 22 additions and 23 deletions

View File

@@ -367,6 +367,11 @@ api.getUserChallenges = {
url: '/challenges/user',
middlewares: [authWithHeaders()],
async handler (req, res) {
req.checkQuery('page').notEmpty().isInt({ min: 0 }, apiError('queryPageInteger'));
const validationErrors = req.validationErrors();
if (validationErrors) throw validationErrors;
const CHALLENGES_PER_PAGE = 10;
const { page } = req.query;