2013-12-25 16:36:33 +02:00
|
|
|
'use strict';
|
2013-05-22 17:03:50 +03:00
|
|
|
/**
|
|
|
|
|
* Module dependencies.
|
|
|
|
|
*/
|
2014-05-02 18:28:24 +03:00
|
|
|
var init = require('./config/init')(),
|
2014-05-20 18:22:38 +03:00
|
|
|
config = require('./config/config'),
|
2014-10-25 01:05:08 +03:00
|
|
|
mongoose = require('mongoose'),
|
|
|
|
|
chalk = require('chalk');
|
2013-05-22 17:03:50 +03:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Main application entry file.
|
|
|
|
|
* Please note that the order of loading is important.
|
|
|
|
|
*/
|
2014-04-21 00:01:01 +03:00
|
|
|
|
2014-01-05 22:58:39 +02:00
|
|
|
// Bootstrap db connection
|
2014-07-31 11:27:14 +03:00
|
|
|
var db = mongoose.connect(config.db, function(err) {
|
|
|
|
|
if (err) {
|
2014-10-25 01:05:08 +03:00
|
|
|
console.error(chalk.red('Could not connect to MongoDB!'));
|
|
|
|
|
console.log(chalk.red(err));
|
2014-08-02 21:29:38 +03:00
|
|
|
}
|
|
|
|
|
});
|
2013-05-22 17:03:50 +03:00
|
|
|
|
2014-08-02 21:29:38 +03:00
|
|
|
// Init the express application
|
|
|
|
|
var app = require('./config/express')(db);
|
2013-05-22 17:03:50 +03:00
|
|
|
|
2014-08-02 21:29:38 +03:00
|
|
|
// Bootstrap passport config
|
|
|
|
|
require('./config/passport')();
|
2013-05-22 17:03:50 +03:00
|
|
|
|
2014-08-02 21:29:38 +03:00
|
|
|
// Start the app by listening on <port>
|
|
|
|
|
app.listen(config.port);
|
2013-06-23 20:53:56 +03:00
|
|
|
|
2014-08-02 21:29:38 +03:00
|
|
|
// Expose app
|
|
|
|
|
exports = module.exports = app;
|
|
|
|
|
|
|
|
|
|
// Logging initialization
|
2014-11-18 23:00:52 +02:00
|
|
|
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));
|
2014-11-26 20:21:08 +02:00
|
|
|
if (process.env.NODE_ENV === 'secure') {
|
|
|
|
|
console.log(chalk.green('HTTPs:\t\t\t\ton'));
|
|
|
|
|
}
|
2014-11-18 23:00:52 +02:00
|
|
|
console.log('--');
|