-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
40 lines (33 loc) · 1.09 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
var express = require('express');
var app = express();
var mongoose = require('mongoose');
var hogan = require('hogan-express');
var config = require('./config/environment/development');
var path = require('path');
var env = process.env.NODE_ENV || 'development';
if (env !== "development") {
config = require('./config/environment/production');
}
var mongoURL = config.mongodb.uri;
var router = express.Router();
mongoose.connect(mongoURL);
require('./models/Students');
require('./models/Event');
require('./routes/index')(router);
require('./routes/students')(router);
require('./routes/events')(router);
var port = process.env.PORT || 8080;
app.set('port', port);
app.engine('html', hogan);
app.set('view engine', 'html');
app.use(express.static(path.join(__dirname, 'public'))); // .public
// Routing
app.use('/', router);
app.use('/students', router);
app.use('/alumni', router);
app.use('/students/:id', router);
app.use('/students/currentStudents', router);
app.use('/events', router);
app.listen(app.get('port'), function() {
console.log('Server started on localhost: ' + app.get('port'));
});