Has anyone managed to get the auto-load functionality of express-resource to work? I cannot get it to fire, but according to the documentation it should work: express-resource
I have tried getting it to work in both my own code and the example code in express-resource provided here. I am simply adding a "console.log" statement into the forum resource's "load" function, however it seems to never be called. Code is as follows:
exports.load = function(id, fn){
console.log('auto-loader');
process.nextTick(function(){
console.log('auto-loader in the callback');
fn(null, { title: 'Ferrets' });
});
};
Then in the "controller.js" the code is exactly as in the example here:
var forums = app.resource('forums', require('./controllers/forum'));
The reason I would like to get this working is that I want to have a blanket function that loads some data for a particular set of routes, as opposed to adding it into each route individually as middleware. E.g. I have "listings" on my site, and I want a function that retrieves the top 10 recent listings.
Any ideas would be greatly appreciated I spent much of last night puzzling and concluding that the code may not work at all. I sincerely hope I'm wrong and hope to stand corrected by one of you smart cookies, because I'd really like it if I did not have to pick a different routing module!
Alternatively if you have a routing module that works with express that you know has functioning auto-load capability then please also let me know?