title: Call function of app.js from within module in node.js?
body: <p>Let's say I have the following app.js (obviously <em>very</em> simplified):</p>
  
  <pre><code>var express = require('express'),
      app = express.createServer();
  
  // include routes
  require('./lib/routes')(app);
  
  // some random function
  var foo = function() {
      return 'bar';
  };
  
  // another random function
  var foo2 = function() {
      return 'bar2';
  };
  </code></pre>
  
  <p>And then I have the routes module:</p>
  
  <pre><code>module.exports = function(app){
      app.get('/some/route', function(req, res){
          var fooBar = foo(),
              fooBar2 = foo2();
  
          res.end(fooBar + fooBar2);
      });
  };
  </code></pre>
  
  <p>This obviously doesn't work since foo and foo2 weren't defined within the module. Is there a way to make this work, or at least a different pattern to better accomplish what this?</p>