aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/middlewares/sort.ts
blob: 632b2fae4158fd2bbfa0ff18e4dbb23844f9d0ca (plain) (tree)
1
2
3
4
5
6
7
8
9



                                                                                                 
                                                    



               
                                                                                                       




                                                    
                                                                                                  
                                                    





                                                                              




                     
import 'express-validator'
import * as express from 'express'

function setUsersSort (req: express.Request, res: express.Response, next: express.NextFunction) {
  if (!req.query.sort) req.query.sort = '-createdAt'

  return next()
}

function setVideoAbusesSort (req: express.Request, res: express.Response, next: express.NextFunction) {
  if (!req.query.sort) req.query.sort = '-createdAt'

  return next()
}

function setVideosSort (req: express.Request, res: express.Response, next: express.NextFunction) {
  if (!req.query.sort) req.query.sort = '-createdAt'

  return next()
}

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

export {
  setUsersSort,
  setVideoAbusesSort,
  setVideosSort
}