Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- /**
- * Module dependencies.
- */
- var init = require('./config/init')(),
- config = require('./config/config'),
- mongoose = require('mongoose'),
- chalk = require('chalk');
- /**
- * Main application entry file.
- * Please note that the order of loading is important.
- */
- // Bootstrap db connection
- var db = mongoose.connect(config.db.uri, config.db.options, function(err) {
- if (err) {
- console.error(chalk.red('Could not connect to MongoDB!'));
- console.log(chalk.red(err));
- }
- });
- mongoose.connection.on('error', function(err) {
- console.error(chalk.red('MongoDB connection error: ' + err));
- process.exit(-1);
- }
- );
- // Init the express application
- // exports = module.exports = io;
- //
- exports.a = 'abc'; // working
- var app = require('./config/express')(db);
- exports.b = 'xyz'; // not working
- var server = require('http').Server(app);
- // module.exports.io = require('socket.io')(server);
- // var session = require('./config/session.js')(db),
- // sharedsession = require('express-socket.io-session');
- // module.exports.io.use(sharedsession(session));
- // Bootstrap passport config
- require('./config/passport')();
- // Expose app
- // used to be exports = module.exports = app;
- console.log('server.js '+JSON.stringify(module.exports));
- // exports = module.exports;
- // Start the app by listening on <port>
- server.listen(config.port);
- // 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));
- if (process.env.NODE_ENV === 'secure') {
- console.log(chalk.green('HTTPs:\t\t\t\ton'));
- }
- console.log('--');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement