Created
January 10, 2012 00:45
-
-
Save deedubs/1586028 to your computer and use it in GitHub Desktop.
Access Express Server Object from Middleware
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
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