Files
meanTorrent/server.js

44 lines
1.1 KiB
JavaScript
Raw Normal View History

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'),
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.
*/
// Bootstrap db connection
2014-07-31 11:27:14 +03:00
var db = mongoose.connect(config.db, function(err) {
if (err) {
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
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));
if (process.env.NODE_ENV === 'secure') {
console.log(chalk.green('HTTPs:\t\t\t\ton'));
}
console.log('--');