aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server.js56
1 files changed, 28 insertions, 28 deletions
diff --git a/server.js b/server.js
index b748a0242..9772ce92b 100644
--- a/server.js
+++ b/server.js
@@ -1,41 +1,41 @@
1'use strict' 1'use strict'
2 2
3// ----------- Node modules ----------- 3// ----------- Node modules -----------
4var bodyParser = require('body-parser') 4const bodyParser = require('body-parser')
5var express = require('express') 5const express = require('express')
6var expressValidator = require('express-validator') 6const expressValidator = require('express-validator')
7var http = require('http') 7const http = require('http')
8var morgan = require('morgan') 8const morgan = require('morgan')
9var path = require('path') 9const path = require('path')
10var TrackerServer = require('bittorrent-tracker').Server 10const TrackerServer = require('bittorrent-tracker').Server
11var WebSocketServer = require('ws').Server 11const WebSocketServer = require('ws').Server
12 12
13// Create our main app 13// Create our main app
14var app = express() 14const app = express()
15 15
16// ----------- Checker ----------- 16// ----------- Checker -----------
17var checker = require('./server/initializers/checker') 17const checker = require('./server/initializers/checker')
18 18
19var miss = checker.checkConfig() 19const miss = checker.checkConfig()
20if (miss.length !== 0) { 20if (miss.length !== 0) {
21 throw new Error('Miss some configurations keys : ' + miss) 21 throw new Error('Miss some configurations keys : ' + miss)
22} 22}
23 23
24// ----------- PeerTube modules ----------- 24// ----------- PeerTube modules -----------
25var config = require('config') 25const config = require('config')
26var constants = require('./server/initializers/constants') 26const constants = require('./server/initializers/constants')
27var customValidators = require('./server/helpers/customValidators') 27const customValidators = require('./server/helpers/customValidators')
28var database = require('./server/initializers/database') 28const database = require('./server/initializers/database')
29var installer = require('./server/initializers/installer') 29const installer = require('./server/initializers/installer')
30var logger = require('./server/helpers/logger') 30const logger = require('./server/helpers/logger')
31var poolRequests = require('./server/lib/poolRequests') 31const poolRequests = require('./server/lib/poolRequests')
32var routes = require('./server/controllers') 32const routes = require('./server/controllers')
33var utils = require('./server/helpers/utils') 33const utils = require('./server/helpers/utils')
34var videos = require('./server/lib/videos') 34const videos = require('./server/lib/videos')
35var webtorrent = require('./server/lib/webtorrent') 35const webtorrent = require('./server/lib/webtorrent')
36 36
37// Get configurations 37// Get configurations
38var port = config.get('listen.port') 38const port = config.get('listen.port')
39 39
40// ----------- Database ----------- 40// ----------- Database -----------
41database.connect() 41database.connect()
@@ -65,7 +65,7 @@ app.use(require('connect-livereload')({
65require('segfault-handler').registerHandler() 65require('segfault-handler').registerHandler()
66 66
67// API routes 67// API routes
68var api_route = '/api/' + constants.API_VERSION 68const api_route = '/api/' + constants.API_VERSION
69app.use(api_route, routes.api) 69app.use(api_route, routes.api)
70 70
71// Static files 71// Static files
@@ -82,7 +82,7 @@ app.use('/*', function (req, res, next) {
82 82
83// ----------- Tracker ----------- 83// ----------- Tracker -----------
84 84
85var trackerServer = new TrackerServer({ 85const trackerServer = new TrackerServer({
86 http: false, 86 http: false,
87 udp: false, 87 udp: false,
88 ws: false, 88 ws: false,
@@ -97,8 +97,8 @@ trackerServer.on('warning', function (err) {
97 logger.error(err) 97 logger.error(err)
98}) 98})
99 99
100var server = http.createServer(app) 100const server = http.createServer(app)
101var wss = new WebSocketServer({server: server, path: '/tracker/socket'}) 101const wss = new WebSocketServer({server: server, path: '/tracker/socket'})
102wss.on('connection', function (ws) { 102wss.on('connection', function (ws) {
103 trackerServer.onWebSocketConnection(ws) 103 trackerServer.onWebSocketConnection(ws)
104}) 104})
@@ -107,7 +107,7 @@ wss.on('connection', function (ws) {
107 107
108// Catch 404 and forward to error handler 108// Catch 404 and forward to error handler
109app.use(function (req, res, next) { 109app.use(function (req, res, next) {
110 var err = new Error('Not Found') 110 const err = new Error('Not Found')
111 err.status = 404 111 err.status = 404
112 next(err) 112 next(err)
113}) 113})