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


                        
               
                     
               

 
                                        
                                                    



               





                                                    
                                         
                                                    






                                                                              
'use strict'

const sortMiddleware = {
  setUsersSort,
  setVideoAbusesSort,
  setVideosSort
}

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

  return next()
}

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

  return next()
}

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

  return next()
}

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

module.exports = sortMiddleware