Skip to content

Instantly share code, notes, and snippets.

@d4goxn
Last active October 20, 2017 17:50
Show Gist options
  • Save d4goxn/6941157 to your computer and use it in GitHub Desktop.
Save d4goxn/6941157 to your computer and use it in GitHub Desktop.
var express = require( 'express' );
app = express();
app.get( '/', function( req, res ) {
console.log( 'app: index' );
res.send( 200 );
});
subApp = express();
subApp.use( function( req, res, next ) {
console.log( 'subApp: middleware, called for app\'s routes, called twice for subApp\'s routes' );
next();
});
subApp.use( '/subapp', function( req, res, next ) {
console.log( 'subApp: middleware, called once for subApp\'s routes' );
next();
});
subApp.get( '/subapp/page', function( req, res ) {
console.log( 'subApp: page' );
res.send( 200 );
});
app.use( subApp );
app.listen( 3000 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment