forked from meamstack/RadarServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
29 lines (22 loc) · 727 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
var express = require('express');
var fs = require('fs');
var path = require('path');
var mongoose = require('mongoose');
mongoose.connect(process.env.RADAR_MONGODB_TEST);
var db = {};
var app = express();
app.directory = __dirname;
require('./config/environments')(app, mongoose);
var modelsPath = path.join(app.directory, '/server/models');
fs.readdirSync(modelsPath).forEach(function (file) {
var name = file.match(/^([a-z]+)\..+$/)[1];
var name = name.charAt(0).toUpperCase() + name.slice(1);
db[name] = require(modelsPath + '/' + file)();
});
require(path.join(app.directory, '/config/environments/passport.js'));
require('./routes')(app);
module.exports = {
app: app,
User: db.User,
Event: db.Event
};