]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/middlewares/reqValidators/sort.js
Add ability to sort videos list
[github/Chocobozzz/PeerTube.git] / server / middlewares / reqValidators / sort.js
1 'use strict'
2
3 const checkErrors = require('./utils').checkErrors
4 const constants = require('../../initializers/constants')
5 const logger = require('../../helpers/logger')
6
7 const reqValidatorsSort = {
8 videosSort: videosSort
9 }
10
11 function videosSort (req, res, next) {
12 const sortableColumns = constants.SORTABLE_COLUMNS.VIDEOS
13
14 req.checkQuery('sort', 'Should have correct sortable column').optional().isIn(sortableColumns)
15
16 logger.debug('Checking sort parameters', { parameters: req.query })
17
18 checkErrors(req, res, next)
19 }
20
21 // ---------------------------------------------------------------------------
22
23 module.exports = reqValidatorsSort