-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
65 lines (44 loc) · 1.31 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var express = require('express'),
api = require('./api'),
port = parseInt(process.env.PORT) || 80,
connect = require('connect');
api.pollSources();
setInterval(api.pollSources, 120000);
var app = module.exports = express.createServer();
// Configuration
app.configure(function(){
app.set('views', __dirname + '/views');
app.use(connect.bodyDecoder());
app.use(connect.methodOverride());
app.use(connect.compiler({ src: __dirname + '/public', enable: ['less'] }));
app.use(app.router);
app.use(connect.staticProvider(__dirname + '/public'));
});
app.configure('development', function(){
app.use(connect.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function(){
app.use(connect.errorHandler());
});
// Routes
app.get('/', function(req, res){
res.render('index.jade', {
locals: {
title: 'eventharvy'
}
});
});
app.get('/fetch', function (req, res) {
res.render('fetch.jade', {
locals: {
title: 'Events',
events: api.events
}
});
});
// Only listen on $ node app.js
if (!module.parent) app.listen(port);
console.log('Eventharvy server running at http://127.0.0.1:' + port);
process.addListener('uncaughtException', function (err) {
console.log(err.stack);
});