It seems it's currently not impossible to place the functions handling the routes outside of the closure, if they need access to the parent context, say things like a database connection.
var FooService = function() {
this.db = connect();
router = new(journey.Router);
router.root(this.handleRequest);
}
FooService.prototype.handleRequest = function(req, res) {
// How do I access the database connection?
}
The documentation points out that I can access the request object via "this.request" in the handle function, but I'm not sure why that is important when the same object is also passed as an argument.
I've seen one other node library that accepted a globalContext argument, which it would then use with apply() when calling functions. which struck me as a nice idea (I'm a node.js/Javascript noob though).
It seems it's currently not impossible to place the functions handling the routes outside of the closure, if they need access to the parent context, say things like a database connection.
The documentation points out that I can access the request object via "this.request" in the handle function, but I'm not sure why that is important when the same object is also passed as an argument.
I've seen one other node library that accepted a globalContext argument, which it would then use with apply() when calling functions. which struck me as a nice idea (I'm a node.js/Javascript noob though).