index.js
This file
Path
examples/vhost/index.js
51 lines · 1023 bytes · JavaScript
Last changed by
deps: update example dependenciesDouglas Christopher Wilsonbefore adoption3205f68
History of this fileTake it
The walk stopped after 200 commits: lines older than f0bfb3b point at it.
3.4.3Jonathan Ongbefore adoptionf0bfb3b
lines 1–5why, one step back1/**2 * Module dependencies.3 */45var express = require('../..');remove last pieces of connect dependencyRoman Shtylmanbefore adoption1396e08
line 6why, one step back6var logger = require('morgan');fix examples for express 4 (separate middleware)Roman Shtylmanbefore adoptionf1315b9
line 7why, one step back7var vhost = require('vhost');3.4.3Jonathan Ongbefore adoptionf0bfb3b
lines 8–20why, one step back89/*10edit /etc/hosts:1112127.0.0.1 foo.example.com13127.0.0.1 bar.example.com14127.0.0.1 example.com15*/1617// Main server app1819var main = express();20deps: update example dependenciesDouglas Christopher Wilsonbefore adoption3205f68
line 21why, one step back21if (!module.parent) main.use(logger('dev'));3.4.3Jonathan Ongbefore adoptionf0bfb3b
lines 22–23why, one step back2223main.get('/', function(req, res){Merge pull request #2008 from agchou/clean-up-codeJonathan Ongbefore adoption2e830ff
line 24why, one step back24 res.send('Hello from main app!');3.4.3Jonathan Ongbefore adoptionf0bfb3b
lines 25–34why, one step back25});2627main.get('/:sub', function(req, res){28 res.send('requested ' + req.params.sub);29});3031// Redirect app3233var redirect = express();34deps: update example dependenciesDouglas Christopher Wilsonbefore adoption3205f68
lines 35–37why, one step back35redirect.use(function(req, res){36 if (!module.parent) console.log(req.vhost);37 res.redirect('http://example.com:3000/' + req.vhost[0]);3.4.3Jonathan Ongbefore adoptionf0bfb3b
lines 38–41why, one step back38});3940// Vhost app41deps: update example dependenciesDouglas Christopher Wilsonbefore adoption3205f68
line 42why, one step back42var app = module.exports = express();3.4.3Jonathan Ongbefore adoptionf0bfb3b
line 43why, one step back43Merge pull request #2008 from agchou/clean-up-codeJonathan Ongbefore adoption2e830ff
line 44why, one step back44app.use(vhost('*.example.com', redirect)); // Serves all subdomains via Redirect appfix examples for express 4 (separate middleware)Roman Shtylmanbefore adoptionf1315b9
line 45why, one step back45app.use(vhost('example.com', main)); // Serves top level domain via Main server app3.4.3Jonathan Ongbefore adoptionf0bfb3b
line 46why, one step back46Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d
lines 47–51why, one step back47/* istanbul ignore next */48if (!module.parent) {49 app.listen(3000);50 console.log('Express started on port 3000');51}