-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
47 lines (34 loc) · 1.04 KB
/
server.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
42
43
44
45
46
47
'use strict';
// Module dependencies.
var express = require('express'),
path = require('path'),
fs = require('fs');
var app = express();
// Connect to database
var db = require('./lib/db/mongo');
// Bootstrap models
var modelsPath = path.join(__dirname, 'lib/models');
fs.readdirSync(modelsPath).forEach(function (file) {
require(modelsPath + '/' + file);
});
// Populate empty DB with dummy data
require('./lib/db/dummydata');
// Express Configuration
require('./lib/config/express')(app);
// Controllers
var api = require('./lib/controllers/api'),
index = require('./lib/controllers');
// Server Routes
app.get('/api/events', api.events);
app.get('/api/awesomeThings', api.awesomeThings);
app.post('/api/events.json', api.newEvent);
// Angular Routes
app.get('/partials/*', index.partials);
app.get('/*', index.index);
// Start server
var port = process.env.PORT || 3000;
app.listen(port, function () {
console.log('Express server listening on port %d in %s mode', port, app.get('env'));
});
// Expose app
exports = module.exports = app;