-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
executable file
·43 lines (35 loc) · 1.1 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
/**
* Module dependencies.
*/
var init = require('./config/init')(),
config = require('./config/config'),
bootstrap = require('./config/bootstrap'),
Sequelize = require('sequelize'),
chalk = require('chalk');
// Bootstrap db connection
var db = new Sequelize(config.db.uri, config.db.options);
db.authenticate()
.then(function () {
return db.sync();
})
.then(function () {
return bootstrap();
})
.catch(function (err) {
console.error(chalk.red('Sequelize connection error: ' + err));
process.exit(-1);
});
var models = require('./config/sequelize').setModels(db);
// Init the express application
var app = require('./config/express')(models);
app.listen(config.port);
// Expose app
module.exports = app;
// Logging initialization
console.log('--');
console.log(chalk.green(config.app.title + ' application started'));
console.log(chalk.green('Environment:\t\t\t' + process.env.NODE_ENV));
console.log(chalk.green('Port:\t\t\t\t' + config.port));
console.log(chalk.green('Database:\t\t\t' + config.db.uri));
console.log('--');