-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
41 lines (35 loc) · 1.07 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Server application main file
*/
'use strict';
var express = require('express'),
config = require('./config/environment'),
mongoose = require('mongoose'),
app = express(),
server = require('http').createServer(app),
async = require('async'),
MONGODB_URI = config.db.baseUrl + config.db.appDB;
require('./config/express')(app);
require('./routes')(app);
async.series([
function connectToMongoDB (next) {
mongoose.connect(MONGODB_URI, {}, function (err) {
if (err) {
return console.log('Erro connecting to mongoDB', err);
} else {
if (app.get('env') !== 'test') {
console.log('Connected to mongoDB.');
}
next();
}
});
},
function startListening () {
server.listen(config.port, function () {
if (app.get('env') !== 'test') {
console.log('Express server listening on port', config.port, 'on', app.get('env'), 'mode');
}
});
}
]);
module.exports = app;