-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (26 loc) · 804 Bytes
/
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
var express = require('express'),
mongoose = require('mongoose'),
fs = require('fs'),
stylus = require('stylus'),
nib = require('nib'),
config = require('./config/config'),
http = require('http'),
https = require('https');
https.globalAgent.maxSockets = 100;
http.globalAgent.maxSockets = 100;
mongoose.connect(config.db_uri, {auth : config.auth});
var db = mongoose.connection;
console.log(db);
db.on('error', function () {
throw new Error('unable to connect to database at ' + config.db);
});
var modelsPath = __dirname + '/app/models';
fs.readdirSync(modelsPath).forEach(function (file) {
if (file.indexOf('.js') >= 0) {
require(modelsPath + '/' + file);
}
});
var app = express();
require('./config/express')(app, config);
require('./config/routes')(app);
app.listen(config.port);