aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/v1/index.js10
-rw-r--r--server/controllers/api/v1/pods.js34
-rw-r--r--server/controllers/api/v1/remoteVideos.js20
-rw-r--r--server/controllers/api/v1/videos.js50
-rw-r--r--server/controllers/index.js4
5 files changed, 59 insertions, 59 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
3var express = require('express') 3const express = require('express')
4 4
5var router = express.Router() 5const router = express.Router()
6 6
7var podsController = require('./pods') 7const podsController = require('./pods')
8var remoteVideosController = require('./remoteVideos') 8const remoteVideosController = require('./remoteVideos')
9var videosController = require('./videos') 9const videosController = require('./videos')
10 10
11router.use('/pods', podsController) 11router.use('/pods', podsController)
12router.use('/remotevideos', remoteVideosController) 12router.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
3var express = require('express') 3const express = require('express')
4var fs = require('fs') 4const fs = require('fs')
5 5
6var logger = require('../../../helpers/logger') 6const logger = require('../../../helpers/logger')
7var friends = require('../../../lib/friends') 7const friends = require('../../../lib/friends')
8var middleware = require('../../../middlewares') 8const middleware = require('../../../middlewares')
9var cacheMiddleware = middleware.cache 9const cacheMiddleware = middleware.cache
10var peertubeCrypto = require('../../../helpers/peertubeCrypto') 10const peertubeCrypto = require('../../../helpers/peertubeCrypto')
11var Pods = require('../../../models/pods') 11const Pods = require('../../../models/pods')
12var reqValidator = middleware.reqValidators.pods 12const reqValidator = middleware.reqValidators.pods
13var secureMiddleware = middleware.secure 13const secureMiddleware = middleware.secure
14var secureRequest = middleware.reqValidators.remote.secureRequest 14const secureRequest = middleware.reqValidators.remote.secureRequest
15var Videos = require('../../../models/videos') 15const Videos = require('../../../models/videos')
16 16
17var router = express.Router() 17const router = express.Router()
18 18
19router.get('/', cacheMiddleware.cache(false), listPods) 19router.get('/', cacheMiddleware.cache(false), listPods)
20router.post('/', reqValidator.podsAdd, cacheMiddleware.cache(false), addPods) 20router.post('/', reqValidator.podsAdd, cacheMiddleware.cache(false), addPods)
@@ -30,7 +30,7 @@ module.exports = router
30// --------------------------------------------------------------------------- 30// ---------------------------------------------------------------------------
31 31
32function addPods (req, res, next) { 32function 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
73function removePods (req, res, next) { 73function 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
3var express = require('express') 3const express = require('express')
4var pluck = require('lodash-node/compat/collection/pluck') 4const pluck = require('lodash-node/compat/collection/pluck')
5 5
6var middleware = require('../../../middlewares') 6const middleware = require('../../../middlewares')
7var secureMiddleware = middleware.secure 7const secureMiddleware = middleware.secure
8var cacheMiddleware = middleware.cache 8const cacheMiddleware = middleware.cache
9var reqValidator = middleware.reqValidators.remote 9const reqValidator = middleware.reqValidators.remote
10var videos = require('../../../models/videos') 10const videos = require('../../../models/videos')
11 11
12var router = express.Router() 12const router = express.Router()
13 13
14router.post('/add', 14router.post('/add',
15 reqValidator.secureRequest, 15 reqValidator.secureRequest,
@@ -42,8 +42,8 @@ function addRemoteVideos (req, res, next) {
42} 42}
43 43
44function removeRemoteVideo (req, res, next) { 44function 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
3var config = require('config') 3const config = require('config')
4var crypto = require('crypto') 4const crypto = require('crypto')
5var express = require('express') 5const express = require('express')
6var multer = require('multer') 6const multer = require('multer')
7 7
8var logger = require('../../../helpers/logger') 8const logger = require('../../../helpers/logger')
9var friends = require('../../../lib/friends') 9const friends = require('../../../lib/friends')
10var middleware = require('../../../middlewares') 10const middleware = require('../../../middlewares')
11var cacheMiddleware = middleware.cache 11const cacheMiddleware = middleware.cache
12var reqValidator = middleware.reqValidators.videos 12const reqValidator = middleware.reqValidators.videos
13var Videos = require('../../../models/videos') // model 13const Videos = require('../../../models/videos') // model
14var videos = require('../../../lib/videos') 14const videos = require('../../../lib/videos')
15var webtorrent = require('../../../lib/webtorrent') 15const webtorrent = require('../../../lib/webtorrent')
16 16
17var router = express.Router() 17const router = express.Router()
18var uploads = config.get('storage.uploads') 18const uploads = config.get('storage.uploads')
19 19
20// multer configuration 20// multer configuration
21var storage = multer.diskStorage({ 21const 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
38var reqFiles = multer({ storage: storage }).fields([{ name: 'input_video', maxCount: 1 }]) 38const reqFiles = multer({ storage: storage }).fields([{ name: 'input_video', maxCount: 1 }])
39 39
40router.get('/', cacheMiddleware.cache(false), listVideos) 40router.get('/', cacheMiddleware.cache(false), listVideos)
41router.post('/', reqFiles, reqValidator.videosAdd, cacheMiddleware.cache(false), addVideo) 41router.post('/', reqFiles, reqValidator.videosAdd, cacheMiddleware.cache(false), addVideo)
@@ -50,8 +50,8 @@ module.exports = router
50// --------------------------------------------------------------------------- 50// ---------------------------------------------------------------------------
51 51
52function addVideo (req, res, next) { 52function 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
105function removeVideo (req, res, next) { 105function 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 }
diff --git a/server/controllers/index.js b/server/controllers/index.js
index 7b0288dbb..4c1d3dafe 100644
--- a/server/controllers/index.js
+++ b/server/controllers/index.js
@@ -1,8 +1,8 @@
1'use strict' 1'use strict'
2 2
3var constants = require('../initializers/constants') 3const constants = require('../initializers/constants')
4 4
5var apiController = require('./api/' + constants.API_VERSION) 5const apiController = require('./api/' + constants.API_VERSION)
6 6
7module.exports = { 7module.exports = {
8 api: apiController 8 api: apiController