From 5c39adb7313e0696aabb4b71196ab7b0b378c359 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 16 Aug 2016 22:31:45 +0200 Subject: Server: add user list sort/pagination --- server/middlewares/validators/sort.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'server/middlewares/validators') diff --git a/server/middlewares/validators/sort.js b/server/middlewares/validators/sort.js index 56b63cc8b..37b34ef52 100644 --- a/server/middlewares/validators/sort.js +++ b/server/middlewares/validators/sort.js @@ -5,9 +5,20 @@ const constants = require('../../initializers/constants') const logger = require('../../helpers/logger') const validatorsSort = { + usersSort: usersSort, videosSort: videosSort } +function usersSort (req, res, next) { + const sortableColumns = constants.SORTABLE_COLUMNS.USERS + + req.checkQuery('sort', 'Should have correct sortable column').optional().isIn(sortableColumns) + + logger.debug('Checking sort parameters', { parameters: req.query }) + + checkErrors(req, res, next) +} + function videosSort (req, res, next) { const sortableColumns = constants.SORTABLE_COLUMNS.VIDEOS -- cgit v1.2.3