forked from metadaddy/Heroku-Connect-Twitter-Demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.js
29 lines (21 loc) · 794 Bytes
/
web.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
var express = require('express');
var app = express();
var create_url = 'https://connect.heroku.com/dashboard-next/create-connection';
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function(){
app.use(express.errorHandler());
});
app.get('/create', function(req, res){
var hostRe = new RegExp(/^([^.]+)\.herokuapp\.com$/);
var match = req.headers.host.match(hostRe);
if (match) {
res.redirect(create_url+'?create='+match[1]);
} else {
res.status(400).send("You need to be running on Heroku!");
}
});
var httpPort = Number(process.env.PORT || 3000);
app.listen(httpPort);
console.log("Express server listening on port %d in %s mode", httpPort, app.settings.env);