2016-05-17 21:03:00 +02:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const sortMiddleware = {
|
2016-10-02 12:19:02 +02:00
|
|
|
setUsersSort,
|
2017-01-04 20:59:23 +01:00
|
|
|
setVideoAbusesSort,
|
2016-10-02 12:19:02 +02:00
|
|
|
setVideosSort
|
2016-05-17 21:03:00 +02:00
|
|
|
}
|
|
|
|
|
2016-08-16 22:31:45 +02:00
|
|
|
function setUsersSort (req, res, next) {
|
2016-12-11 21:50:51 +01:00
|
|
|
if (!req.query.sort) req.query.sort = '-createdAt'
|
2016-08-16 22:31:45 +02:00
|
|
|
|
|
|
|
return next()
|
|
|
|
}
|
|
|
|
|
2017-01-04 20:59:23 +01:00
|
|
|
function setVideoAbusesSort (req, res, next) {
|
|
|
|
if (!req.query.sort) req.query.sort = '-createdAt'
|
|
|
|
|
|
|
|
return next()
|
|
|
|
}
|
|
|
|
|
2016-05-17 21:03:00 +02:00
|
|
|
function setVideosSort (req, res, next) {
|
2016-12-11 21:50:51 +01:00
|
|
|
if (!req.query.sort) req.query.sort = '-createdAt'
|
2016-05-17 21:03:00 +02:00
|
|
|
|
|
|
|
return next()
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
module.exports = sortMiddleware
|