]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/middlewares/validators/sort.js
3 const checkErrors
= require('./utils').checkErrors
4 const constants
= require('../../initializers/constants')
5 const logger
= require('../../helpers/logger')
7 const validatorsSort
= {
13 function usersSort (req
, res
, next
) {
14 const sortableColumns
= constants
.SORTABLE_COLUMNS
.USERS
16 checkSort(req
, res
, next
, sortableColumns
)
19 function videoAbusesSort (req
, res
, next
) {
20 const sortableColumns
= constants
.SORTABLE_COLUMNS
.VIDEO_ABUSES
22 checkSort(req
, res
, next
, sortableColumns
)
25 function videosSort (req
, res
, next
) {
26 const sortableColumns
= constants
.SORTABLE_COLUMNS
.VIDEOS
28 checkSort(req
, res
, next
, sortableColumns
)
31 // ---------------------------------------------------------------------------
33 module
.exports
= validatorsSort
35 // ---------------------------------------------------------------------------
37 function checkSort (req
, res
, next
, sortableColumns
) {
38 req
.checkQuery('sort', 'Should have correct sortable column').optional().isIn(sortableColumns
)
40 logger
.debug('Checking sort parameters', { parameters: req
.query
})
42 checkErrors(req
, res
, next
)