-
Notifications
You must be signed in to change notification settings - Fork 5
/
server.js
48 lines (38 loc) · 1.03 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
var config = require('./config');
var express = require('express')
var session = require('express-session');
var request = require('request');
var calRoute = require('./routes/calendar.js');
var app = express();
var port = 8080;
// Alternates:
// http://www.huffingtonpost.ca/feeds/index.xml
// http://rss.cbc.ca/lineup/topstories.xml
var newsConfig = {
url: "http://www.huffingtonpost.ca/feeds/index.xml"
};
// Your own super cool function
var logger = function(req, res, next) {
console.log(req.method + " request to " + req.url);
next();
}
app.all("*", logger);
app.use(express.static(__dirname + "/public"));
app.use(session({
secret: config.session_secret,
resave: true,
saveUninitialized: true
}));
// Calendar stuff
app.all('/cal', calRoute);
app.get('/feed', function(req, res) {
request(newsConfig.url, function (error, response, body) {
if (!error && response.statusCode == 200) {
res.write(body);
res.end();
}
});
});
app.listen(port, function() {
console.log("Server running on localhost:" + port)
});