Skip to content

Instantly share code, notes, and snippets.

@deedubs
Created January 10, 2012 00:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deedubs/1586028 to your computer and use it in GitHub Desktop.
Save deedubs/1586028 to your computer and use it in GitHub Desktop.
Access Express Server Object from Middleware
....
var myplugin = express.createServer()
, ready = false;
myplugin.get('/:verb/allthe/:nouns', function(req, res) {
if(ready) {
console.log(myplugin.app); // here too
}
res.send('Yeah you' + req.params.verb + ' all those ' + req.params.nouns);
});
myplugin.on('mount', function(app) {
//app here
ready = true;
});
module.exports = myplugin;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment