2016-05-17 14:03:00 -05:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const sortMiddleware = {
|
2016-10-02 05:19:02 -05:00
|
|
|
setUsersSort,
|
|
|
|
setVideosSort
|
2016-05-17 14:03:00 -05:00
|
|
|
}
|
|
|
|
|
2016-08-16 15:31:45 -05:00
|
|
|
function setUsersSort (req, res, next) {
|
2016-12-11 14:50:51 -06:00
|
|
|
if (!req.query.sort) req.query.sort = '-createdAt'
|
2016-08-16 15:31:45 -05:00
|
|
|
|
|
|
|
return next()
|
|
|
|
}
|
|
|
|
|
2016-05-17 14:03:00 -05:00
|
|
|
function setVideosSort (req, res, next) {
|
2016-12-11 14:50:51 -06:00
|
|
|
if (!req.query.sort) req.query.sort = '-createdAt'
|
2016-05-17 14:03:00 -05:00
|
|
|
|
|
|
|
return next()
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
module.exports = sortMiddleware
|