diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-03-16 22:29:27 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-03-16 22:29:27 +0100 |
commit | f0f5567b6918fc60c8cab15e13aec03a89a91dfb (patch) | |
tree | 99dfdb9fa8273c9cda1360fd3b6bfccc515bf8be /server/controllers/api/v1 | |
parent | 5101105ef91bfe478f97546b78b321882da2079c (diff) | |
download | PeerTube-f0f5567b6918fc60c8cab15e13aec03a89a91dfb.tar.gz PeerTube-f0f5567b6918fc60c8cab15e13aec03a89a91dfb.tar.zst PeerTube-f0f5567b6918fc60c8cab15e13aec03a89a91dfb.zip |
Use const/let now we use node 4.2
Diffstat (limited to 'server/controllers/api/v1')
-rw-r--r-- | server/controllers/api/v1/index.js | 10 | ||||
-rw-r--r-- | server/controllers/api/v1/pods.js | 34 | ||||
-rw-r--r-- | server/controllers/api/v1/remoteVideos.js | 20 | ||||
-rw-r--r-- | server/controllers/api/v1/videos.js | 50 |
4 files changed, 57 insertions, 57 deletions
diff --git a/server/controllers/api/v1/index.js b/server/controllers/api/v1/index.js index b562bc2af..45f07ae1f 100644 --- a/server/controllers/api/v1/index.js +++ b/server/controllers/api/v1/index.js | |||
@@ -1,12 +1,12 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | var express = require('express') | 3 | const express = require('express') |
4 | 4 | ||
5 | var router = express.Router() | 5 | const router = express.Router() |
6 | 6 | ||
7 | var podsController = require('./pods') | 7 | const podsController = require('./pods') |
8 | var remoteVideosController = require('./remoteVideos') | 8 | const remoteVideosController = require('./remoteVideos') |
9 | var videosController = require('./videos') | 9 | const videosController = require('./videos') |
10 | 10 | ||
11 | router.use('/pods', podsController) | 11 | router.use('/pods', podsController) |
12 | router.use('/remotevideos', remoteVideosController) | 12 | router.use('/remotevideos', remoteVideosController) |
diff --git a/server/controllers/api/v1/pods.js b/server/controllers/api/v1/pods.js index fa9832914..dbe1a7372 100644 --- a/server/controllers/api/v1/pods.js +++ b/server/controllers/api/v1/pods.js | |||
@@ -1,20 +1,20 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | var express = require('express') | 3 | const express = require('express') |
4 | var fs = require('fs') | 4 | const fs = require('fs') |
5 | 5 | ||
6 | var logger = require('../../../helpers/logger') | 6 | const logger = require('../../../helpers/logger') |
7 | var friends = require('../../../lib/friends') | 7 | const friends = require('../../../lib/friends') |
8 | var middleware = require('../../../middlewares') | 8 | const middleware = require('../../../middlewares') |
9 | var cacheMiddleware = middleware.cache | 9 | const cacheMiddleware = middleware.cache |
10 | var peertubeCrypto = require('../../../helpers/peertubeCrypto') | 10 | const peertubeCrypto = require('../../../helpers/peertubeCrypto') |
11 | var Pods = require('../../../models/pods') | 11 | const Pods = require('../../../models/pods') |
12 | var reqValidator = middleware.reqValidators.pods | 12 | const reqValidator = middleware.reqValidators.pods |
13 | var secureMiddleware = middleware.secure | 13 | const secureMiddleware = middleware.secure |
14 | var secureRequest = middleware.reqValidators.remote.secureRequest | 14 | const secureRequest = middleware.reqValidators.remote.secureRequest |
15 | var Videos = require('../../../models/videos') | 15 | const Videos = require('../../../models/videos') |
16 | 16 | ||
17 | var router = express.Router() | 17 | const router = express.Router() |
18 | 18 | ||
19 | router.get('/', cacheMiddleware.cache(false), listPods) | 19 | router.get('/', cacheMiddleware.cache(false), listPods) |
20 | router.post('/', reqValidator.podsAdd, cacheMiddleware.cache(false), addPods) | 20 | router.post('/', reqValidator.podsAdd, cacheMiddleware.cache(false), addPods) |
@@ -30,7 +30,7 @@ module.exports = router | |||
30 | // --------------------------------------------------------------------------- | 30 | // --------------------------------------------------------------------------- |
31 | 31 | ||
32 | function addPods (req, res, next) { | 32 | function addPods (req, res, next) { |
33 | var informations = req.body.data | 33 | const informations = req.body.data |
34 | Pods.add(informations, function (err) { | 34 | Pods.add(informations, function (err) { |
35 | if (err) return next(err) | 35 | if (err) return next(err) |
36 | 36 | ||
@@ -71,7 +71,7 @@ function makeFriends (req, res, next) { | |||
71 | } | 71 | } |
72 | 72 | ||
73 | function removePods (req, res, next) { | 73 | function removePods (req, res, next) { |
74 | var url = req.body.signature.url | 74 | const url = req.body.signature.url |
75 | Pods.remove(url, function (err) { | 75 | Pods.remove(url, function (err) { |
76 | if (err) return next(err) | 76 | if (err) return next(err) |
77 | 77 | ||
diff --git a/server/controllers/api/v1/remoteVideos.js b/server/controllers/api/v1/remoteVideos.js index 7622e39f5..58222de52 100644 --- a/server/controllers/api/v1/remoteVideos.js +++ b/server/controllers/api/v1/remoteVideos.js | |||
@@ -1,15 +1,15 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | var express = require('express') | 3 | const express = require('express') |
4 | var pluck = require('lodash-node/compat/collection/pluck') | 4 | const pluck = require('lodash-node/compat/collection/pluck') |
5 | 5 | ||
6 | var middleware = require('../../../middlewares') | 6 | const middleware = require('../../../middlewares') |
7 | var secureMiddleware = middleware.secure | 7 | const secureMiddleware = middleware.secure |
8 | var cacheMiddleware = middleware.cache | 8 | const cacheMiddleware = middleware.cache |
9 | var reqValidator = middleware.reqValidators.remote | 9 | const reqValidator = middleware.reqValidators.remote |
10 | var videos = require('../../../models/videos') | 10 | const videos = require('../../../models/videos') |
11 | 11 | ||
12 | var router = express.Router() | 12 | const router = express.Router() |
13 | 13 | ||
14 | router.post('/add', | 14 | router.post('/add', |
15 | reqValidator.secureRequest, | 15 | reqValidator.secureRequest, |
@@ -42,8 +42,8 @@ function addRemoteVideos (req, res, next) { | |||
42 | } | 42 | } |
43 | 43 | ||
44 | function removeRemoteVideo (req, res, next) { | 44 | function removeRemoteVideo (req, res, next) { |
45 | var url = req.body.signature.url | 45 | const url = req.body.signature.url |
46 | var magnetUris = pluck(req.body.data, 'magnetUri') | 46 | const magnetUris = pluck(req.body.data, 'magnetUri') |
47 | 47 | ||
48 | videos.removeRemotesOfByMagnetUris(url, magnetUris, function (err) { | 48 | videos.removeRemotesOfByMagnetUris(url, magnetUris, function (err) { |
49 | if (err) return next(err) | 49 | if (err) return next(err) |
diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js index 76cad62d1..1eea417d4 100644 --- a/server/controllers/api/v1/videos.js +++ b/server/controllers/api/v1/videos.js | |||
@@ -1,41 +1,41 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | var config = require('config') | 3 | const config = require('config') |
4 | var crypto = require('crypto') | 4 | const crypto = require('crypto') |
5 | var express = require('express') | 5 | const express = require('express') |
6 | var multer = require('multer') | 6 | const multer = require('multer') |
7 | 7 | ||
8 | var logger = require('../../../helpers/logger') | 8 | const logger = require('../../../helpers/logger') |
9 | var friends = require('../../../lib/friends') | 9 | const friends = require('../../../lib/friends') |
10 | var middleware = require('../../../middlewares') | 10 | const middleware = require('../../../middlewares') |
11 | var cacheMiddleware = middleware.cache | 11 | const cacheMiddleware = middleware.cache |
12 | var reqValidator = middleware.reqValidators.videos | 12 | const reqValidator = middleware.reqValidators.videos |
13 | var Videos = require('../../../models/videos') // model | 13 | const Videos = require('../../../models/videos') // model |
14 | var videos = require('../../../lib/videos') | 14 | const videos = require('../../../lib/videos') |
15 | var webtorrent = require('../../../lib/webtorrent') | 15 | const webtorrent = require('../../../lib/webtorrent') |
16 | 16 | ||
17 | var router = express.Router() | 17 | const router = express.Router() |
18 | var uploads = config.get('storage.uploads') | 18 | const uploads = config.get('storage.uploads') |
19 | 19 | ||
20 | // multer configuration | 20 | // multer configuration |
21 | var storage = multer.diskStorage({ | 21 | const storage = multer.diskStorage({ |
22 | destination: function (req, file, cb) { | 22 | destination: function (req, file, cb) { |
23 | cb(null, uploads) | 23 | cb(null, uploads) |
24 | }, | 24 | }, |
25 | 25 | ||
26 | filename: function (req, file, cb) { | 26 | filename: function (req, file, cb) { |
27 | var extension = '' | 27 | let extension = '' |
28 | if (file.mimetype === 'video/webm') extension = 'webm' | 28 | if (file.mimetype === 'video/webm') extension = 'webm' |
29 | else if (file.mimetype === 'video/mp4') extension = 'mp4' | 29 | else if (file.mimetype === 'video/mp4') extension = 'mp4' |
30 | else if (file.mimetype === 'video/ogg') extension = 'ogv' | 30 | else if (file.mimetype === 'video/ogg') extension = 'ogv' |
31 | crypto.pseudoRandomBytes(16, function (err, raw) { | 31 | crypto.pseudoRandomBytes(16, function (err, raw) { |
32 | var fieldname = err ? undefined : raw.toString('hex') | 32 | const fieldname = err ? undefined : raw.toString('hex') |
33 | cb(null, fieldname + '.' + extension) | 33 | cb(null, fieldname + '.' + extension) |
34 | }) | 34 | }) |
35 | } | 35 | } |
36 | }) | 36 | }) |
37 | 37 | ||
38 | var reqFiles = multer({ storage: storage }).fields([{ name: 'input_video', maxCount: 1 }]) | 38 | const reqFiles = multer({ storage: storage }).fields([{ name: 'input_video', maxCount: 1 }]) |
39 | 39 | ||
40 | router.get('/', cacheMiddleware.cache(false), listVideos) | 40 | router.get('/', cacheMiddleware.cache(false), listVideos) |
41 | router.post('/', reqFiles, reqValidator.videosAdd, cacheMiddleware.cache(false), addVideo) | 41 | router.post('/', reqFiles, reqValidator.videosAdd, cacheMiddleware.cache(false), addVideo) |
@@ -50,8 +50,8 @@ module.exports = router | |||
50 | // --------------------------------------------------------------------------- | 50 | // --------------------------------------------------------------------------- |
51 | 51 | ||
52 | function addVideo (req, res, next) { | 52 | function addVideo (req, res, next) { |
53 | var video_file = req.files.input_video[0] | 53 | const video_file = req.files.input_video[0] |
54 | var video_infos = req.body | 54 | const video_infos = req.body |
55 | 55 | ||
56 | videos.seed(video_file.path, function (err, torrent) { | 56 | videos.seed(video_file.path, function (err, torrent) { |
57 | if (err) { | 57 | if (err) { |
@@ -59,7 +59,7 @@ function addVideo (req, res, next) { | |||
59 | return next(err) | 59 | return next(err) |
60 | } | 60 | } |
61 | 61 | ||
62 | var video_data = { | 62 | const video_data = { |
63 | name: video_infos.name, | 63 | name: video_infos.name, |
64 | namePath: video_file.filename, | 64 | namePath: video_file.filename, |
65 | description: video_infos.description, | 65 | description: video_infos.description, |
@@ -103,7 +103,7 @@ function listVideos (req, res, next) { | |||
103 | } | 103 | } |
104 | 104 | ||
105 | function removeVideo (req, res, next) { | 105 | function removeVideo (req, res, next) { |
106 | var video_id = req.params.id | 106 | const video_id = req.params.id |
107 | Videos.get(video_id, function (err, video) { | 107 | Videos.get(video_id, function (err, video) { |
108 | if (err) return next(err) | 108 | if (err) return next(err) |
109 | 109 | ||
@@ -111,7 +111,7 @@ function removeVideo (req, res, next) { | |||
111 | Videos.removeOwned(req.params.id, function (err) { | 111 | Videos.removeOwned(req.params.id, function (err) { |
112 | if (err) return next(err) | 112 | if (err) return next(err) |
113 | 113 | ||
114 | var params = { | 114 | const params = { |
115 | name: video.name, | 115 | name: video.name, |
116 | magnetUri: video.magnetUri | 116 | magnetUri: video.magnetUri |
117 | } | 117 | } |