Update node modules

This commit is contained in:
Chocobozzz 2015-12-04 21:43:26 +01:00
parent 155098af55
commit 207fbab44d
5 changed files with 19 additions and 16 deletions

View File

@ -24,8 +24,8 @@
} }
videos.videosAdd = function (req, res, next) { videos.videosAdd = function (req, res, next) {
req.checkFiles('input_video.originalname', 'Should have an input video').notEmpty() req.checkFiles('input_video[0].originalname', 'Should have an input video').notEmpty()
req.checkFiles('input_video.mimetype', 'Should have a correct mime type').matches(/video\/(webm)|(mp4)|(ogg)/i) req.checkFiles('input_video[0].mimetype', 'Should have a correct mime type').matches(/video\/(webm)|(mp4)|(ogg)/i)
req.checkBody('name', 'Should have a name').isLength(1, 50) req.checkBody('name', 'Should have a name').isLength(1, 50)
req.checkBody('description', 'Should have a description').isLength(1, 250) req.checkBody('description', 'Should have a description').isLength(1, 250)

View File

@ -36,8 +36,8 @@
"grunt": "^0.4.5", "grunt": "^0.4.5",
"grunt-browserify": "^4.0.1", "grunt-browserify": "^4.0.1",
"grunt-concurrent": "^2.1.0", "grunt-concurrent": "^2.1.0",
"grunt-contrib-clean": "^0.6.0", "grunt-contrib-clean": "^0.7.0",
"grunt-contrib-copy": "0.8.0", "grunt-contrib-copy": "0.8.2",
"grunt-contrib-watch": "^0.6.1", "grunt-contrib-watch": "^0.6.1",
"grunt-express-server": "^0.5.1", "grunt-express-server": "^0.5.1",
"grunt-newer": "^1.1.1", "grunt-newer": "^1.1.1",
@ -50,17 +50,17 @@
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"mongoose": "^4.0.5", "mongoose": "^4.0.5",
"morgan": "^1.5.3", "morgan": "^1.5.3",
"multer": "^0.1.8", "multer": "^1.1.0",
"node-ipc": "^3.0.0", "node-ipc": "^4.1.0",
"openssl-wrapper": "https://github.com/Chocobozzz/node-openssl-wrapper", "openssl-wrapper": "https://github.com/Chocobozzz/node-openssl-wrapper",
"request": "^2.57.0", "request": "^2.57.0",
"request-replay": "^0.3.0", "request-replay": "^0.3.0",
"segfault-handler": "^0.2.4", "segfault-handler": "^1.0.0",
"time-grunt": "^1.2.1", "time-grunt": "^1.2.1",
"ursa": "^0.9.1", "ursa": "^0.9.1",
"validator": "^4.3.0", "validator": "^4.3.0",
"webtorrent": "*", "webtorrent": "^0.63.2",
"winston": "^1.0.1", "winston": "^2.1.1",
"ws": "^0.8.0" "ws": "^0.8.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -2,12 +2,17 @@
'use strict' 'use strict'
var express = require('express') var express = require('express')
var config = require('config')
var multer = require('multer')
var router = express.Router() var router = express.Router()
var middleware = require('../../../middlewares') var middleware = require('../../../middlewares')
var miscMiddleware = middleware.misc var miscMiddleware = middleware.misc
var reqValidator = middleware.reqValidators.videos var reqValidator = middleware.reqValidators.videos
var videos = require('../../../src/videos') var videos = require('../../../src/videos')
var uploads = config.get('storage.uploads')
function listVideos (req, res, next) { function listVideos (req, res, next) {
videos.list(function (err, videos_list) { videos.list(function (err, videos_list) {
if (err) return next(err) if (err) return next(err)
@ -25,7 +30,7 @@
} }
function addVideos (req, res, next) { function addVideos (req, res, next) {
videos.add({ video: req.files.input_video, data: req.body }, function (err) { videos.add({ video: req.files.input_video[0], data: req.body }, function (err) {
if (err) return next(err) if (err) return next(err)
// TODO : include Location of the new video // TODO : include Location of the new video
@ -53,8 +58,10 @@
}) })
} }
var reqFiles = multer({ dest: uploads }).fields([{ name: 'input_video', maxCount: 1 }])
router.get('/', miscMiddleware.cache(false), listVideos) router.get('/', miscMiddleware.cache(false), listVideos)
router.post('/', reqValidator.videosAdd, miscMiddleware.cache(false), addVideos) router.post('/', reqFiles, reqValidator.videosAdd, miscMiddleware.cache(false), addVideos)
router.get('/search/:name', reqValidator.videosSearch, miscMiddleware.cache(false), searchVideos) router.get('/search/:name', reqValidator.videosSearch, miscMiddleware.cache(false), searchVideos)
router.get('/:id', reqValidator.videosGet, miscMiddleware.cache(false), getVideos) router.get('/:id', reqValidator.videosGet, miscMiddleware.cache(false), getVideos)
router.delete('/:id', reqValidator.videosRemove, miscMiddleware.cache(false), removeVideo) router.delete('/:id', reqValidator.videosRemove, miscMiddleware.cache(false), removeVideo)

View File

@ -7,7 +7,6 @@
var expressValidator = require('express-validator') var expressValidator = require('express-validator')
var http = require('http') var http = require('http')
var morgan = require('morgan') var morgan = require('morgan')
var multer = require('multer')
var path = require('path') var path = require('path')
var TrackerServer = require('bittorrent-tracker').Server var TrackerServer = require('bittorrent-tracker').Server
var WebSocketServer = require('ws').Server var WebSocketServer = require('ws').Server
@ -44,7 +43,6 @@
// Get configurations // Get configurations
var port = config.get('listen.port') var port = config.get('listen.port')
var uploads = config.get('storage.uploads')
// ----------- Command line ----------- // ----------- Command line -----------
@ -54,8 +52,6 @@
app.use(morgan('combined', { stream: logger.stream })) app.use(morgan('combined', { stream: logger.stream }))
// For body requests // For body requests
app.use(bodyParser.json()) app.use(bodyParser.json())
// For POST file requests
app.use(multer({ dest: uploads }))
app.use(bodyParser.urlencoded({ extended: false })) app.use(bodyParser.urlencoded({ extended: false }))
// Validate some params for the API // Validate some params for the API
app.use(expressValidator({ app.use(expressValidator({

View File

@ -56,7 +56,7 @@
var params = { var params = {
name: video_data.name, name: video_data.name,
namePath: video_file.name, namePath: video_file.filename,
description: video_data.description, description: video_data.description,
magnetUri: torrent.magnetURI, magnetUri: torrent.magnetURI,
podUrl: http + '://' + host + ':' + port podUrl: http + '://' + host + ':' + port