Skip to content
Myr

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 file

Take it

The walk stopped after 200 commits: lines older than 34c83d7 point at it.

3.4.7Jonathan Ongbefore adoption34c83d7

lines 1–5why, one step back
1/**
2 * Module dependencies.3 */45var express = require('../..');

remove last pieces of connect dependencyRoman Shtylmanbefore adoption1396e08

line 6why, one step back
6var logger = require('morgan');

fix examples for express 4 (separate middleware)Roman Shtylmanbefore adoptionf1315b9

line 7why, one step back
7var vhost = require('vhost');

3.4.7Jonathan Ongbefore adoption34c83d7

lines 8–20why, one step back
8
9/*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();20

deps: update example dependenciesDouglas Christopher Wilsonbefore adoption3205f68

line 21why, one step back
21if (!module.parent) main.use(logger('dev'));

3.4.7Jonathan Ongbefore adoption34c83d7

lines 22–23why, one step back
22
23main.get('/', function(req, res){

Merge pull request #2008 from agchou/clean-up-codeJonathan Ongbefore adoption2e830ff

line 24why, one step back
24 res.send('Hello from main app!');

3.4.7Jonathan Ongbefore adoption34c83d7

lines 25–34why, one step back
25});
2627main.get('/:sub', function(req, res){28 res.send('requested ' + req.params.sub);29});3031// Redirect app3233var redirect = express();34

deps: update example dependenciesDouglas Christopher Wilsonbefore adoption3205f68

lines 35–37why, one step back
35redirect.use(function(req, res){
36 if (!module.parent) console.log(req.vhost);37 res.redirect('http://example.com:3000/' + req.vhost[0]);

3.4.7Jonathan Ongbefore adoption34c83d7

lines 38–41why, one step back
38});
3940// Vhost app41

deps: update example dependenciesDouglas Christopher Wilsonbefore adoption3205f68

line 42why, one step back
42var app = module.exports = express();

3.4.7Jonathan Ongbefore adoption34c83d7

line 43why, one step back
43

Merge pull request #2008 from agchou/clean-up-codeJonathan Ongbefore adoption2e830ff

line 44why, one step back
44app.use(vhost('*.example.com', redirect)); // Serves all subdomains via Redirect app

fix examples for express 4 (separate middleware)Roman Shtylmanbefore adoptionf1315b9

line 45why, one step back
45app.use(vhost('example.com', main)); // Serves top level domain via Main server app

3.4.7Jonathan Ongbefore adoption34c83d7

line 46why, one step back
46

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

lines 47–51why, one step back
47/* istanbul ignore next */
48if (!module.parent) {49 app.listen(3000);50 console.log('Express started on port 3000');51}