-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
24 lines (19 loc) · 681 Bytes
/
server.js
File metadata and controls
24 lines (19 loc) · 681 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var requestProxy = require('express-request-proxy');
var express = require('express'),
port = process.env.PORT || 3000,
app = express();
var proxyGitHub = function(request, response) {
console.log('Routing GitHub request for', request.params[0]);
(requestProxy({
url: 'https://api.github.com/' + request.params[0],
headers: { Authorization: 'token ' + process.env.GITHUB_TOKEN }
}))(request, response);
};
app.get('/github/*', proxyGitHub);
app.use(express.static('./'));
app.get('*', function(request, response) {
response.sendFile('index.html', { root: '.' });
});
app.listen(port, function() {
console.log('Server started on port ' + port + '!');
});