aboutsummaryrefslogtreecommitdiffhomepage
path: root/server.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-10-02 15:39:09 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-10-02 15:39:09 +0200
commita6375e69668ea42e19531c6bc68dcd37f3f7cbd7 (patch)
tree03204a408d56311692c3528bedcf95d2455e94f2 /server.js
parent052937db8a8d282eccdbdf38d487ed8d85d3c0a7 (diff)
parentc4403b29ad4db097af528a7f04eea07e0ed320d0 (diff)
downloadPeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.gz
PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.tar.zst
PeerTube-a6375e69668ea42e19531c6bc68dcd37f3f7cbd7.zip
Merge branch 'master' into webseed-merged
Diffstat (limited to 'server.js')
-rw-r--r--server.js33
1 files changed, 21 insertions, 12 deletions
diff --git a/server.js b/server.js
index 0033ed1db..5feb21476 100644
--- a/server.js
+++ b/server.js
@@ -32,6 +32,7 @@ if (miss.length !== 0) {
32// ----------- PeerTube modules ----------- 32// ----------- PeerTube modules -----------
33const customValidators = require('./server/helpers/custom-validators') 33const customValidators = require('./server/helpers/custom-validators')
34const installer = require('./server/initializers/installer') 34const installer = require('./server/initializers/installer')
35const migrator = require('./server/initializers/migrator')
35const mongoose = require('mongoose') 36const mongoose = require('mongoose')
36const routes = require('./server/controllers') 37const routes = require('./server/controllers')
37const Request = mongoose.model('Request') 38const Request = mongoose.model('Request')
@@ -46,18 +47,21 @@ const port = config.get('listen.port')
46// For the logger 47// For the logger
47app.use(morgan('combined', { stream: logger.stream })) 48app.use(morgan('combined', { stream: logger.stream }))
48// For body requests 49// For body requests
49app.use(bodyParser.json()) 50app.use(bodyParser.json({ limit: '500kb' }))
50app.use(bodyParser.urlencoded({ extended: false })) 51app.use(bodyParser.urlencoded({ extended: false }))
51// Validate some params for the API 52// Validate some params for the API
52app.use(expressValidator({ 53app.use(expressValidator({
53 customValidators: customValidators 54 customValidators: Object.assign(
55 {},
56 customValidators.misc,
57 customValidators.pods,
58 customValidators.users,
59 customValidators.videos
60 )
54})) 61}))
55 62
56// ----------- Views, routes and static files ----------- 63// ----------- Views, routes and static files -----------
57 64
58// Catch sefaults
59require('segfault-handler').registerHandler()
60
61// API routes 65// API routes
62const apiRoute = '/api/' + constants.API_VERSION 66const apiRoute = '/api/' + constants.API_VERSION
63app.use(apiRoute, routes.api) 67app.use(apiRoute, routes.api)
@@ -125,14 +129,19 @@ app.use(function (err, req, res, next) {
125installer.installApplication(function (err) { 129installer.installApplication(function (err) {
126 if (err) throw err 130 if (err) throw err
127 131
128 // ----------- Make the server listening ----------- 132 // Run the migration scripts if needed
129 server.listen(port, function () { 133 migrator.migrate(function (err) {
130 // Activate the pool requests 134 if (err) throw err
131 Request.activate() 135
136 // ----------- Make the server listening -----------
137 server.listen(port, function () {
138 // Activate the pool requests
139 Request.activate()
132 140
133 logger.info('Seeded all the videos') 141 logger.info('Seeded all the videos')
134 logger.info('Server listening on port %d', port) 142 logger.info('Server listening on port %d', port)
135 app.emit('ready') 143 app.emit('ready')
144 })
136 }) 145 })
137}) 146})
138 147