Created
January 30, 2012 21:03
-
-
Save shiawuen/1706682 to your computer and use it in GitHub Desktop.
Async dynamic helper for Express
This file contains 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 yourAsyncDynamicHelper = require('./yourAsyncDynamicHelper') | |
app.configure(function(){ | |
// | |
// other middlewares | |
// | |
app.use(yourAsyncDynamicHelper()); | |
// | |
// other middlewares | |
// | |
}); | |
app.dynamicHelpers({ | |
data: function(req, res) { return req.your.dynamic.data; } | |
}); |
This file contains 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
module.exports = function(options) { | |
return function(req, res, next) { | |
// do your async stuff here to get your data | |
req.your.dynamic.data = 'some async data'; | |
next(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment