aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/v1/videos.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-22 09:15:00 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-22 09:15:00 +0200
commit46246b5f194caafba4e3a72e9365acd8b35785de (patch)
tree943689b44a9e447872cd7dd1c2a70dcc9256b990 /server/controllers/api/v1/videos.js
parent68ce3ae021c9bc11b155044df6d23ba60e91eee4 (diff)
downloadPeerTube-46246b5f194caafba4e3a72e9365acd8b35785de.tar.gz
PeerTube-46246b5f194caafba4e3a72e9365acd8b35785de.tar.zst
PeerTube-46246b5f194caafba4e3a72e9365acd8b35785de.zip
Extends the search feature by customizing the search field (name,
podUrl...)
Diffstat (limited to 'server/controllers/api/v1/videos.js')
-rw-r--r--server/controllers/api/v1/videos.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js
index f7aeea453..7f59dd232 100644
--- a/server/controllers/api/v1/videos.js
+++ b/server/controllers/api/v1/videos.js
@@ -17,6 +17,7 @@ const reqValidator = middlewares.reqValidators
17const reqValidatorPagination = reqValidator.pagination 17const reqValidatorPagination = reqValidator.pagination
18const reqValidatorSort = reqValidator.sort 18const reqValidatorSort = reqValidator.sort
19const reqValidatorVideos = reqValidator.videos 19const reqValidatorVideos = reqValidator.videos
20const search = middlewares.search
20const sort = middlewares.sort 21const sort = middlewares.sort
21const utils = require('../../../helpers/utils') 22const utils = require('../../../helpers/utils')
22const Videos = require('../../../models/videos') // model 23const Videos = require('../../../models/videos') // model
@@ -69,12 +70,13 @@ router.delete('/:id',
69 reqValidatorVideos.videosRemove, 70 reqValidatorVideos.videosRemove,
70 removeVideo 71 removeVideo
71) 72)
72router.get('/search/:name', 73router.get('/search/:value',
73 reqValidatorVideos.videosSearch, 74 reqValidatorVideos.videosSearch,
74 reqValidatorPagination.pagination, 75 reqValidatorPagination.pagination,
75 reqValidatorSort.videosSort, 76 reqValidatorSort.videosSort,
76 sort.setVideosSort, 77 sort.setVideosSort,
77 pagination.setPagination, 78 pagination.setPagination,
79 search.setVideosSearch,
78 searchVideos 80 searchVideos
79) 81)
80 82
@@ -237,7 +239,8 @@ function removeVideo (req, res, next) {
237} 239}
238 240
239function searchVideos (req, res, next) { 241function searchVideos (req, res, next) {
240 Videos.search(req.params.name, req.query.start, req.query.count, req.query.sort, function (err, videosList, totalVideos) { 242 Videos.search(req.params.value, req.query.field, req.query.start, req.query.count, req.query.sort,
243 function (err, videosList, totalVideos) {
241 if (err) return next(err) 244 if (err) return next(err)
242 245
243 res.json(getFormatedVideos(videosList, totalVideos)) 246 res.json(getFormatedVideos(videosList, totalVideos))