title: How does mounting apps in Express work
body: <p>So I've seen <a href="https://vimeo.com/56166857" rel="nofollow">TJ's guide to creating modular Express-apps</a>, followed it to good effects, but want to know more about the details of how it works, however a search gives me no answers.</p>
  
  <p><strong>In short I am wondering:</strong>  When mounting apps in Express, what parts of the apps are shared and what parts are not?</p>
  
  <p>Some examples to clarify my question: </p>
  
  <p>app.js:</p>
  
  <pre><code>app.use(express.bodyParser()); 
  
  app.use(loginApi); //loginApi is an express app 
  
  app.listen(3000);
  </code></pre>
  
  <p>This example works. But if I place the <code>app.use(loginApi)</code> before <code>app.use(express.bodyParser());</code> , the body parser will not be available in the loginApi subapp. Why is that?</p>
  
  <p>Another example:</p>
  
  <p>submodule.js</p>
  
  <pre><code>var app = module.exports = require('express')();
  app.all('*', function(req, res, next){
      console.log('nifty middleware');
          next();
  });
  </code></pre>
  
  <p>app.js</p>
  
  <pre><code>app.get('/funtimes', fn);
  app.use(submodule); 
  app.listen(3000);
  </code></pre>
  
  <p>Now in this example, If I understand it correctly, the <code>/funtimes</code> route will not be affected by the submodule middleware for all routes. But what about the rest of the routes of app.js ? Will they be affected? And what if I add another module, will it be affected? </p>