aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/middlewares/sort.js
blob: 8ed15780587355c949ae1a3b569e57fb3cc6a84b (plain) (tree)
1
2
3
4
5
6
7


                        
                             


                              





                                                      








                                                                              
'use strict'

const sortMiddleware = {
  setUsersSort: setUsersSort,
  setVideosSort: setVideosSort
}

function setUsersSort (req, res, next) {
  if (!req.query.sort) req.query.sort = '-createdDate'

  return next()
}

function setVideosSort (req, res, next) {
  if (!req.query.sort) req.query.sort = '-createdDate'

  return next()
}

// ---------------------------------------------------------------------------

module.exports = sortMiddleware