PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/server/app.js

https://gitlab.com/ewhalan/mining-webui
JavaScript | 37 lines | 20 code | 8 blank | 9 comment | 2 complexity | 90f734821bb8372a889020f1cdb9bc56 MD5 | raw file
  1. /**
  2. * Main application file
  3. */
  4. 'use strict';
  5. // Set default node environment to development
  6. process.env.NODE_ENV = process.env.NODE_ENV || 'development';
  7. var express = require('express');
  8. var mongoose = require('mongoose');
  9. var config = require('./config/environment');
  10. // Connect to database
  11. mongoose.connect(config.mongo.uri, config.mongo.options);
  12. // Populate DB with sample data
  13. if(config.seedDB) { require('./config/seed'); }
  14. // Setup server
  15. var app = express();
  16. var server = require('http').createServer(app);
  17. var socketio = require('socket.io')(server, {
  18. serveClient: (config.env === 'production') ? false : true,
  19. path: '/socket.io-client'
  20. });
  21. require('./config/socketio')(socketio);
  22. require('./config/express')(app);
  23. require('./routes')(app);
  24. // Start server
  25. server.listen(config.port, config.ip, function () {
  26. console.log('Express server listening on %d, in %s mode', config.port, app.get('env'));
  27. });
  28. // Expose app
  29. exports = module.exports = app;