aboutsummaryrefslogtreecommitdiffhomepage
path: root/routes/api/v1
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2015-12-04 21:43:26 +0100
committerChocobozzz <florian.bigard@gmail.com>2015-12-04 21:43:26 +0100
commit207fbab44d04ec92d748b6a32ec9a237029f820b (patch)
treef5878ab3b56e33fecf6aba1836883771fcba8638 /routes/api/v1
parent155098af555ef94fb543beb8b82d21523362a7c7 (diff)
downloadPeerTube-207fbab44d04ec92d748b6a32ec9a237029f820b.tar.gz
PeerTube-207fbab44d04ec92d748b6a32ec9a237029f820b.tar.zst
PeerTube-207fbab44d04ec92d748b6a32ec9a237029f820b.zip
Update node modules
Diffstat (limited to 'routes/api/v1')
-rw-r--r--routes/api/v1/videos.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/routes/api/v1/videos.js b/routes/api/v1/videos.js
index 33c565437..ae70d1640 100644
--- a/routes/api/v1/videos.js
+++ b/routes/api/v1/videos.js
@@ -2,12 +2,17 @@
2 'use strict' 2 'use strict'
3 3
4 var express = require('express') 4 var express = require('express')
5 var config = require('config')
6 var multer = require('multer')
5 var router = express.Router() 7 var router = express.Router()
8
6 var middleware = require('../../../middlewares') 9 var middleware = require('../../../middlewares')
7 var miscMiddleware = middleware.misc 10 var miscMiddleware = middleware.misc
8 var reqValidator = middleware.reqValidators.videos 11 var reqValidator = middleware.reqValidators.videos
9 var videos = require('../../../src/videos') 12 var videos = require('../../../src/videos')
10 13
14 var uploads = config.get('storage.uploads')
15
11 function listVideos (req, res, next) { 16 function listVideos (req, res, next) {
12 videos.list(function (err, videos_list) { 17 videos.list(function (err, videos_list) {
13 if (err) return next(err) 18 if (err) return next(err)
@@ -25,7 +30,7 @@
25 } 30 }
26 31
27 function addVideos (req, res, next) { 32 function addVideos (req, res, next) {
28 videos.add({ video: req.files.input_video, data: req.body }, function (err) { 33 videos.add({ video: req.files.input_video[0], data: req.body }, function (err) {
29 if (err) return next(err) 34 if (err) return next(err)
30 35
31 // TODO : include Location of the new video 36 // TODO : include Location of the new video
@@ -53,8 +58,10 @@
53 }) 58 })
54 } 59 }
55 60
61 var reqFiles = multer({ dest: uploads }).fields([{ name: 'input_video', maxCount: 1 }])
62
56 router.get('/', miscMiddleware.cache(false), listVideos) 63 router.get('/', miscMiddleware.cache(false), listVideos)
57 router.post('/', reqValidator.videosAdd, miscMiddleware.cache(false), addVideos) 64 router.post('/', reqFiles, reqValidator.videosAdd, miscMiddleware.cache(false), addVideos)
58 router.get('/search/:name', reqValidator.videosSearch, miscMiddleware.cache(false), searchVideos) 65 router.get('/search/:name', reqValidator.videosSearch, miscMiddleware.cache(false), searchVideos)
59 router.get('/:id', reqValidator.videosGet, miscMiddleware.cache(false), getVideos) 66 router.get('/:id', reqValidator.videosGet, miscMiddleware.cache(false), getVideos)
60 router.delete('/:id', reqValidator.videosRemove, miscMiddleware.cache(false), removeVideo) 67 router.delete('/:id', reqValidator.videosRemove, miscMiddleware.cache(false), removeVideo)