diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2015-12-04 21:43:26 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2015-12-04 21:43:26 +0100 |
commit | 207fbab44d04ec92d748b6a32ec9a237029f820b (patch) | |
tree | f5878ab3b56e33fecf6aba1836883771fcba8638 | |
parent | 155098af555ef94fb543beb8b82d21523362a7c7 (diff) | |
download | PeerTube-207fbab44d04ec92d748b6a32ec9a237029f820b.tar.gz PeerTube-207fbab44d04ec92d748b6a32ec9a237029f820b.tar.zst PeerTube-207fbab44d04ec92d748b6a32ec9a237029f820b.zip |
Update node modules
-rw-r--r-- | middlewares/reqValidators/videos.js | 4 | ||||
-rw-r--r-- | package.json | 14 | ||||
-rw-r--r-- | routes/api/v1/videos.js | 11 | ||||
-rw-r--r-- | server.js | 4 | ||||
-rw-r--r-- | src/videos.js | 2 |
5 files changed, 19 insertions, 16 deletions
diff --git a/middlewares/reqValidators/videos.js b/middlewares/reqValidators/videos.js index 3763a657c..8c4e23b6b 100644 --- a/middlewares/reqValidators/videos.js +++ b/middlewares/reqValidators/videos.js | |||
@@ -24,8 +24,8 @@ | |||
24 | } | 24 | } |
25 | 25 | ||
26 | videos.videosAdd = function (req, res, next) { | 26 | videos.videosAdd = function (req, res, next) { |
27 | req.checkFiles('input_video.originalname', 'Should have an input video').notEmpty() | 27 | req.checkFiles('input_video[0].originalname', 'Should have an input video').notEmpty() |
28 | req.checkFiles('input_video.mimetype', 'Should have a correct mime type').matches(/video\/(webm)|(mp4)|(ogg)/i) | 28 | req.checkFiles('input_video[0].mimetype', 'Should have a correct mime type').matches(/video\/(webm)|(mp4)|(ogg)/i) |
29 | req.checkBody('name', 'Should have a name').isLength(1, 50) | 29 | req.checkBody('name', 'Should have a name').isLength(1, 50) |
30 | req.checkBody('description', 'Should have a description').isLength(1, 250) | 30 | req.checkBody('description', 'Should have a description').isLength(1, 250) |
31 | 31 | ||
diff --git a/package.json b/package.json index 8f2ed9e74..26161cd76 100644 --- a/package.json +++ b/package.json | |||
@@ -36,8 +36,8 @@ | |||
36 | "grunt": "^0.4.5", | 36 | "grunt": "^0.4.5", |
37 | "grunt-browserify": "^4.0.1", | 37 | "grunt-browserify": "^4.0.1", |
38 | "grunt-concurrent": "^2.1.0", | 38 | "grunt-concurrent": "^2.1.0", |
39 | "grunt-contrib-clean": "^0.6.0", | 39 | "grunt-contrib-clean": "^0.7.0", |
40 | "grunt-contrib-copy": "0.8.0", | 40 | "grunt-contrib-copy": "0.8.2", |
41 | "grunt-contrib-watch": "^0.6.1", | 41 | "grunt-contrib-watch": "^0.6.1", |
42 | "grunt-express-server": "^0.5.1", | 42 | "grunt-express-server": "^0.5.1", |
43 | "grunt-newer": "^1.1.1", | 43 | "grunt-newer": "^1.1.1", |
@@ -50,17 +50,17 @@ | |||
50 | "mkdirp": "^0.5.1", | 50 | "mkdirp": "^0.5.1", |
51 | "mongoose": "^4.0.5", | 51 | "mongoose": "^4.0.5", |
52 | "morgan": "^1.5.3", | 52 | "morgan": "^1.5.3", |
53 | "multer": "^0.1.8", | 53 | "multer": "^1.1.0", |
54 | "node-ipc": "^3.0.0", | 54 | "node-ipc": "^4.1.0", |
55 | "openssl-wrapper": "https://github.com/Chocobozzz/node-openssl-wrapper", | 55 | "openssl-wrapper": "https://github.com/Chocobozzz/node-openssl-wrapper", |
56 | "request": "^2.57.0", | 56 | "request": "^2.57.0", |
57 | "request-replay": "^0.3.0", | 57 | "request-replay": "^0.3.0", |
58 | "segfault-handler": "^0.2.4", | 58 | "segfault-handler": "^1.0.0", |
59 | "time-grunt": "^1.2.1", | 59 | "time-grunt": "^1.2.1", |
60 | "ursa": "^0.9.1", | 60 | "ursa": "^0.9.1", |
61 | "validator": "^4.3.0", | 61 | "validator": "^4.3.0", |
62 | "webtorrent": "*", | 62 | "webtorrent": "^0.63.2", |
63 | "winston": "^1.0.1", | 63 | "winston": "^2.1.1", |
64 | "ws": "^0.8.0" | 64 | "ws": "^0.8.0" |
65 | }, | 65 | }, |
66 | "devDependencies": { | 66 | "devDependencies": { |
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) |
@@ -7,7 +7,6 @@ | |||
7 | var expressValidator = require('express-validator') | 7 | var expressValidator = require('express-validator') |
8 | var http = require('http') | 8 | var http = require('http') |
9 | var morgan = require('morgan') | 9 | var morgan = require('morgan') |
10 | var multer = require('multer') | ||
11 | var path = require('path') | 10 | var path = require('path') |
12 | var TrackerServer = require('bittorrent-tracker').Server | 11 | var TrackerServer = require('bittorrent-tracker').Server |
13 | var WebSocketServer = require('ws').Server | 12 | var WebSocketServer = require('ws').Server |
@@ -44,7 +43,6 @@ | |||
44 | 43 | ||
45 | // Get configurations | 44 | // Get configurations |
46 | var port = config.get('listen.port') | 45 | var port = config.get('listen.port') |
47 | var uploads = config.get('storage.uploads') | ||
48 | 46 | ||
49 | // ----------- Command line ----------- | 47 | // ----------- Command line ----------- |
50 | 48 | ||
@@ -54,8 +52,6 @@ | |||
54 | app.use(morgan('combined', { stream: logger.stream })) | 52 | app.use(morgan('combined', { stream: logger.stream })) |
55 | // For body requests | 53 | // For body requests |
56 | app.use(bodyParser.json()) | 54 | app.use(bodyParser.json()) |
57 | // For POST file requests | ||
58 | app.use(multer({ dest: uploads })) | ||
59 | app.use(bodyParser.urlencoded({ extended: false })) | 55 | app.use(bodyParser.urlencoded({ extended: false })) |
60 | // Validate some params for the API | 56 | // Validate some params for the API |
61 | app.use(expressValidator({ | 57 | app.use(expressValidator({ |
diff --git a/src/videos.js b/src/videos.js index e3a5b49f1..32f26abe7 100644 --- a/src/videos.js +++ b/src/videos.js | |||
@@ -56,7 +56,7 @@ | |||
56 | 56 | ||
57 | var params = { | 57 | var params = { |
58 | name: video_data.name, | 58 | name: video_data.name, |
59 | namePath: video_file.name, | 59 | namePath: video_file.filename, |
60 | description: video_data.description, | 60 | description: video_data.description, |
61 | magnetUri: torrent.magnetURI, | 61 | magnetUri: torrent.magnetURI, |
62 | podUrl: http + '://' + host + ':' + port | 62 | podUrl: http + '://' + host + ':' + port |