aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/v1/videos.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-17 21:03:00 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-17 21:03:00 +0200
commita877d5acc5c52b8667c65f725bbca9a52e40ec48 (patch)
tree20b5dd56f71c7572360807f894e85e0ab729629f /server/controllers/api/v1/videos.js
parent479f229198bdfcfd3a63d02babdddaa8b2209ccb (diff)
downloadPeerTube-a877d5acc5c52b8667c65f725bbca9a52e40ec48.tar.gz
PeerTube-a877d5acc5c52b8667c65f725bbca9a52e40ec48.tar.zst
PeerTube-a877d5acc5c52b8667c65f725bbca9a52e40ec48.zip
Add ability to sort videos list
Diffstat (limited to 'server/controllers/api/v1/videos.js')
-rw-r--r--server/controllers/api/v1/videos.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js
index c6dbfbaf2..73e496ace 100644
--- a/server/controllers/api/v1/videos.js
+++ b/server/controllers/api/v1/videos.js
@@ -15,7 +15,9 @@ const oAuth2 = middlewares.oauth2
15const pagination = middlewares.pagination 15const pagination = middlewares.pagination
16const reqValidator = middlewares.reqValidators 16const reqValidator = middlewares.reqValidators
17const reqValidatorPagination = reqValidator.pagination 17const reqValidatorPagination = reqValidator.pagination
18const reqValidatorSort = reqValidator.sort
18const reqValidatorVideos = reqValidator.videos 19const reqValidatorVideos = reqValidator.videos
20const sort = middlewares.sort
19const utils = require('../../../helpers/utils') 21const utils = require('../../../helpers/utils')
20const Videos = require('../../../models/videos') // model 22const Videos = require('../../../models/videos') // model
21const videos = require('../../../lib/videos') 23const videos = require('../../../lib/videos')
@@ -47,6 +49,8 @@ const thumbnailsDir = path.join(__dirname, '..', '..', '..', '..', config.get('s
47 49
48router.get('/', 50router.get('/',
49 reqValidatorPagination.pagination, 51 reqValidatorPagination.pagination,
52 reqValidatorSort.videosSort,
53 sort.setVideosSort,
50 pagination.setPagination, 54 pagination.setPagination,
51 listVideos 55 listVideos
52) 56)
@@ -68,6 +72,8 @@ router.delete('/:id',
68router.get('/search/:name', 72router.get('/search/:name',
69 reqValidatorVideos.videosSearch, 73 reqValidatorVideos.videosSearch,
70 reqValidatorPagination.pagination, 74 reqValidatorPagination.pagination,
75 reqValidatorSort.videosSort,
76 sort.setVideosSort,
71 pagination.setPagination, 77 pagination.setPagination,
72 searchVideos 78 searchVideos
73) 79)
@@ -173,7 +179,7 @@ function getVideos (req, res, next) {
173} 179}
174 180
175function listVideos (req, res, next) { 181function listVideos (req, res, next) {
176 Videos.list(req.query.start, req.query.count, function (err, videosList) { 182 Videos.list(req.query.start, req.query.count, req.query.sort, function (err, videosList) {
177 if (err) return next(err) 183 if (err) return next(err)
178 184
179 res.json(getFormatedVideos(videosList)) 185 res.json(getFormatedVideos(videosList))
@@ -231,7 +237,7 @@ function removeVideo (req, res, next) {
231} 237}
232 238
233function searchVideos (req, res, next) { 239function searchVideos (req, res, next) {
234 Videos.search(req.params.name, req.query.start, req.query.count, function (err, videosList) { 240 Videos.search(req.params.name, req.query.start, req.query.count, req.query.sort, function (err, videosList) {
235 if (err) return next(err) 241 if (err) return next(err)
236 242
237 res.json(getFormatedVideos(videosList)) 243 res.json(getFormatedVideos(videosList))