7 var express = require('../..');
8 var logger = require('morgan');
9 var vhost = require('vhost');
14 127.0.0.1 foo.example.com
15 127.0.0.1 bar.example.com
23 if (!module.parent) main.use(logger('dev'));
25 main.get('/', function(req, res){
26 res.send('Hello from main app!');
29 main.get('/:sub', function(req, res){
30 res.send('requested ' + req.params.sub);
35 var redirect = express();
37 redirect.use(function(req, res){
38 if (!module.parent) console.log(req.vhost);
39 res.redirect('http://example.com:3000/' + req.vhost[0]);
44 var app = module.exports = express();
46 app.use(vhost('*.example.com', redirect)); // Serves all subdomains via Redirect app
47 app.use(vhost('example.com', main)); // Serves top level domain via Main server app
49 /* istanbul ignore next */
52 console.log('Express started on port 3000');