Advertisement
Guest User

Untitled

a guest
Jun 8th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2. /**
  3.  * Module dependencies.
  4.  */
  5. var init = require('./config/init')(),
  6.     config = require('./config/config'),
  7.     mongoose = require('mongoose'),
  8.     chalk = require('chalk');
  9.  
  10. /**
  11.  * Main application entry file.
  12.  * Please note that the order of loading is important.
  13.  */
  14.  
  15. // Bootstrap db connection
  16. var db = mongoose.connect(config.db.uri, config.db.options, function(err) {
  17.     if (err) {
  18.         console.error(chalk.red('Could not connect to MongoDB!'));
  19.         console.log(chalk.red(err));
  20.     }
  21. });
  22. mongoose.connection.on('error', function(err) {
  23.     console.error(chalk.red('MongoDB connection error: ' + err));
  24.     process.exit(-1);
  25.     }
  26. );
  27.  
  28. // Init the express application
  29. // exports = module.exports = io;
  30. //
  31.  
  32. exports.a = 'abc'; // working
  33.  
  34. var app = require('./config/express')(db);
  35.  
  36. exports.b = 'xyz'; // not working
  37.  
  38. var server = require('http').Server(app);
  39. // module.exports.io = require('socket.io')(server);
  40. // var  session = require('./config/session.js')(db),
  41. //  sharedsession = require('express-socket.io-session');
  42.  
  43. // module.exports.io.use(sharedsession(session));
  44.  
  45. // Bootstrap passport config
  46. require('./config/passport')();
  47.  
  48.  
  49. // Expose app
  50. // used to be exports = module.exports = app;
  51.  
  52.  
  53. console.log('server.js '+JSON.stringify(module.exports));
  54.  
  55. // exports = module.exports;
  56.  
  57. // Start the app by listening on <port>
  58. server.listen(config.port);
  59.  
  60.  
  61.  
  62.  
  63. // Logging initialization
  64. console.log('--');
  65. console.log(chalk.green(config.app.title + ' application started'));
  66. console.log(chalk.green('Environment:\t\t\t' + process.env.NODE_ENV));
  67. console.log(chalk.green('Port:\t\t\t\t' + config.port));
  68. console.log(chalk.green('Database:\t\t\t' + config.db.uri));
  69. if (process.env.NODE_ENV === 'secure') {
  70.     console.log(chalk.green('HTTPs:\t\t\t\ton'));
  71. }
  72. console.log('--');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement