diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-10-02 15:39:09 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-10-02 15:39:09 +0200 |
commit | a6375e69668ea42e19531c6bc68dcd37f3f7cbd7 (patch) | |
tree | 03204a408d56311692c3528bedcf95d2455e94f2 /server.js | |
parent | 052937db8a8d282eccdbdf38d487ed8d85d3c0a7 (diff) | |
parent | c4403b29ad4db097af528a7f04eea07e0ed320d0 (diff) | |
download | PeerTube-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.js | 33 |
1 files changed, 21 insertions, 12 deletions
@@ -32,6 +32,7 @@ if (miss.length !== 0) { | |||
32 | // ----------- PeerTube modules ----------- | 32 | // ----------- PeerTube modules ----------- |
33 | const customValidators = require('./server/helpers/custom-validators') | 33 | const customValidators = require('./server/helpers/custom-validators') |
34 | const installer = require('./server/initializers/installer') | 34 | const installer = require('./server/initializers/installer') |
35 | const migrator = require('./server/initializers/migrator') | ||
35 | const mongoose = require('mongoose') | 36 | const mongoose = require('mongoose') |
36 | const routes = require('./server/controllers') | 37 | const routes = require('./server/controllers') |
37 | const Request = mongoose.model('Request') | 38 | const Request = mongoose.model('Request') |
@@ -46,18 +47,21 @@ const port = config.get('listen.port') | |||
46 | // For the logger | 47 | // For the logger |
47 | app.use(morgan('combined', { stream: logger.stream })) | 48 | app.use(morgan('combined', { stream: logger.stream })) |
48 | // For body requests | 49 | // For body requests |
49 | app.use(bodyParser.json()) | 50 | app.use(bodyParser.json({ limit: '500kb' })) |
50 | app.use(bodyParser.urlencoded({ extended: false })) | 51 | app.use(bodyParser.urlencoded({ extended: false })) |
51 | // Validate some params for the API | 52 | // Validate some params for the API |
52 | app.use(expressValidator({ | 53 | app.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 | ||
59 | require('segfault-handler').registerHandler() | ||
60 | |||
61 | // API routes | 65 | // API routes |
62 | const apiRoute = '/api/' + constants.API_VERSION | 66 | const apiRoute = '/api/' + constants.API_VERSION |
63 | app.use(apiRoute, routes.api) | 67 | app.use(apiRoute, routes.api) |
@@ -125,14 +129,19 @@ app.use(function (err, req, res, next) { | |||
125 | installer.installApplication(function (err) { | 129 | installer.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 | ||