mirror of
https://github.com/mmumshad/ansible-playable.git
synced 2025-03-09 23:38:54 +00:00
Initial Commit
This commit is contained in:
commit
c92f737237
273 changed files with 16964 additions and 0 deletions
38
server/app.js
Normal file
38
server/app.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* Main application file
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import express from 'express';
|
||||
import mongoose from 'mongoose';
|
||||
mongoose.Promise = require('bluebird');
|
||||
import config from './config/environment';
|
||||
import http from 'http';
|
||||
import seedDatabaseIfNeeded from './config/seed';
|
||||
|
||||
// Connect to MongoDB
|
||||
mongoose.connect(config.mongo.uri, config.mongo.options);
|
||||
mongoose.connection.on('error', function(err) {
|
||||
console.error(`MongoDB connection error: ${err}`);
|
||||
process.exit(-1); // eslint-disable-line no-process-exit
|
||||
});
|
||||
|
||||
// Setup server
|
||||
var app = express();
|
||||
var server = http.createServer(app);
|
||||
require('./config/express').default(app);
|
||||
require('./routes').default(app);
|
||||
|
||||
// Start server
|
||||
function startServer() {
|
||||
app.angularFullstack = server.listen(config.port, config.ip, function() {
|
||||
console.log('Express server listening on %d, in %s mode', config.port, app.get('env'));
|
||||
});
|
||||
}
|
||||
|
||||
seedDatabaseIfNeeded();
|
||||
setImmediate(startServer);
|
||||
|
||||
// Expose app
|
||||
exports = module.exports = app;
|
Loading…
Add table
Add a link
Reference in a new issue