updated server constructor to start properly
This commit is contained in:
parent
74f96dacfb
commit
db306b9901
4 changed files with 12 additions and 15 deletions
2
index.js
2
index.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -22,7 +22,7 @@ module.exports = (db) => {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
return new PassportLocalStrategy(
|
return new PassportLocalStrategy(
|
||||||
{
|
{
|
||||||
|
|
21
server.js
21
server.js
|
@ -19,9 +19,12 @@ function SpeechServer (config) {
|
||||||
this.mysqlConfig = config.mysql;
|
this.mysqlConfig = config.mysql;
|
||||||
this.siteConfig = config.siteConfig;
|
this.siteConfig = config.siteConfig;
|
||||||
this.lbrynetConfig = config.lbrynetConfig;
|
this.lbrynetConfig = config.lbrynetConfig;
|
||||||
this.db = require('./models')(this.mysqlConfig);
|
this.db = require('./models')(config.mysqlConfig);
|
||||||
this.PORT = 3000;
|
this.PORT = 3000;
|
||||||
this.app = (function () {
|
this.speak = (something) => {
|
||||||
|
console.log(something);
|
||||||
|
};
|
||||||
|
this.start = () => {
|
||||||
// trust the proxy to get ip address for us
|
// trust the proxy to get ip address for us
|
||||||
app.enable('trust proxy');
|
app.enable('trust proxy');
|
||||||
|
|
||||||
|
@ -69,16 +72,11 @@ function SpeechServer (config) {
|
||||||
require('./routes/serve-routes.js')(app);
|
require('./routes/serve-routes.js')(app);
|
||||||
require('./routes/fallback-routes.js')(app);
|
require('./routes/fallback-routes.js')(app);
|
||||||
|
|
||||||
return app;
|
|
||||||
}());
|
|
||||||
this.server = (function () {
|
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
return http.Server(this.app);
|
const server = http.Server(app);
|
||||||
})();
|
this.startServer(server);
|
||||||
this.speak = (something) => {
|
|
||||||
console.log(something);
|
|
||||||
};
|
};
|
||||||
this.start = () => {
|
this.startServer = (server) => {
|
||||||
// print config variables
|
// print config variables
|
||||||
require('./helpers/configVarCheck.js')(this.config);
|
require('./helpers/configVarCheck.js')(this.config);
|
||||||
this.db.sequelize
|
this.db.sequelize
|
||||||
|
@ -86,8 +84,7 @@ function SpeechServer (config) {
|
||||||
.sync()
|
.sync()
|
||||||
// start the server
|
// start the server
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.server.listen(this.PORT, () => {
|
server.listen(this.PORT, () => {
|
||||||
logger.info('Trusting proxy?', this.app.get('trust proxy'));
|
|
||||||
logger.info(`Server is listening on PORT ${this.PORT}`);
|
logger.info(`Server is listening on PORT ${this.PORT}`);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue