X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server.js;h=d38c5830f3f0ac565fbfdbe4b5554c98dc7c2bad;hb=7eef95353f9202e1f3285606282fc8fd904c90ef;hp=33e34019d96333f80f9b57fa60db0d9947f099b8;hpb=00057e85a703713a8f0d96e01c49978be0987eb2;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server.js b/server.js index 33e34019d..d38c5830f 100644 --- a/server.js +++ b/server.js @@ -13,14 +13,6 @@ const WebSocketServer = require('ws').Server // Create our main app const app = express() -// ----------- Checker ----------- -const checker = require('./server/initializers/checker') - -const miss = checker.checkConfig() -if (miss.length !== 0) { - throw new Error('Miss some configurations keys : ' + miss) -} - // ----------- Database ----------- const config = require('config') const constants = require('./server/initializers/constants') @@ -29,14 +21,23 @@ const logger = require('./server/helpers/logger') database.connect() +// ----------- Checker ----------- +const checker = require('./server/initializers/checker') + +const miss = checker.checkConfig() +if (miss.length !== 0) { + throw new Error('Miss some configurations keys : ' + miss) +} + // ----------- PeerTube modules ----------- -const customValidators = require('./server/helpers/customValidators') +const customValidators = require('./server/helpers/custom-validators') const installer = require('./server/initializers/installer') const mongoose = require('mongoose') const routes = require('./server/controllers') const utils = require('./server/helpers/utils') const webtorrent = require('./server/lib/webtorrent') const Request = mongoose.model('Request') +const Video = mongoose.model('Video') // Get configurations const port = config.get('listen.port') @@ -52,7 +53,7 @@ app.use(bodyParser.json()) app.use(bodyParser.urlencoded({ extended: false })) // Validate some params for the API app.use(expressValidator({ - customValidators: customValidators + customValidators: Object.assign({}, customValidators.misc, customValidators.users, customValidators.videos) })) // ----------- Views, routes and static files ----------- @@ -139,11 +140,13 @@ installer.installApplication(function (err) { // Activate the pool requests Request.activate() - // videos.seedAllExisting(function () { + Video.seedAllExisting(function (err) { + if (err) throw err + logger.info('Seeded all the videos') logger.info('Server listening on port %d', port) app.emit('ready') - // }) + }) }) }) })