title: Access "app" variable inside of ExpressJS/ConnectJS middleware?
body: <p>This may not me be the right approach, but I want to conditionally add an object/parameter to the <code>app</code> variable inside of an expressJS/connectjS middleware call.</p>
  
  <p>Since this function is a callback, what's the standard/best way to access <code>app</code> from inside a middleware call?</p>
  
  <pre><code>  //app.js
    var myMiddleware = require('./lib/mymiddleware.js');
    ...
    app.configure( function(){
      app.use( myMiddleware.func() );
      ...
    }
  
    if( 'object' !== typeof app.myObject ){
      cry( 'about it' );
    } 
  
  
    //mymiddleware.js
    module.exports.func = function( ){
      return function( req, res, next ){
         //append app object
         //app.myObject = {}
         next();
      }
    };
  </code></pre>
  
  <p>Note, this is not something for <code>locals</code> or <code>settings</code> to later be rendered, but something that will be used in routes and sockets later down the execution chain.</p>