]>
Commit | Line | Data |
---|---|---|
1 | 'use strict' | |
2 | ||
3 | const sortMiddleware = { | |
4 | setUsersSort, | |
5 | setVideoAbusesSort, | |
6 | setVideosSort | |
7 | } | |
8 | ||
9 | function setUsersSort (req, res, next) { | |
10 | if (!req.query.sort) req.query.sort = '-createdAt' | |
11 | ||
12 | return next() | |
13 | } | |
14 | ||
15 | function setVideoAbusesSort (req, res, next) { | |
16 | if (!req.query.sort) req.query.sort = '-createdAt' | |
17 | ||
18 | return next() | |
19 | } | |
20 | ||
21 | function setVideosSort (req, res, next) { | |
22 | if (!req.query.sort) req.query.sort = '-createdAt' | |
23 | ||
24 | return next() | |
25 | } | |
26 | ||
27 | // --------------------------------------------------------------------------- | |
28 | ||
29 | module.exports = sortMiddleware |