diff options
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/v1/videos.js | 7 |
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 | |||
17 | const reqValidatorPagination = reqValidator.pagination | 17 | const reqValidatorPagination = reqValidator.pagination |
18 | const reqValidatorSort = reqValidator.sort | 18 | const reqValidatorSort = reqValidator.sort |
19 | const reqValidatorVideos = reqValidator.videos | 19 | const reqValidatorVideos = reqValidator.videos |
20 | const search = middlewares.search | ||
20 | const sort = middlewares.sort | 21 | const sort = middlewares.sort |
21 | const utils = require('../../../helpers/utils') | 22 | const utils = require('../../../helpers/utils') |
22 | const Videos = require('../../../models/videos') // model | 23 | const Videos = require('../../../models/videos') // model |
@@ -69,12 +70,13 @@ router.delete('/:id', | |||
69 | reqValidatorVideos.videosRemove, | 70 | reqValidatorVideos.videosRemove, |
70 | removeVideo | 71 | removeVideo |
71 | ) | 72 | ) |
72 | router.get('/search/:name', | 73 | router.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 | ||
239 | function searchVideos (req, res, next) { | 241 | function 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)) |