I can’t seem to find a reference to the old self.loader function which allowed us to work with req.extras, now req.data.
I tried creating a simple extension of ‘apostrophe-module’ using enableMiddleware. This is the code
var _ = require(‘lodash’);
module.exports = {
extends:'apostrophe-module',
construct:function(self,options){
console.log("Construct ");
self.enableMiddleware = function(){
console.log("Enabling middlewares");
self.apos.app.use(self.addDefaults);
};
self.addDefaults = function(req, res, next){
console.log("running?");
req.data.defaults = {"hello":"world"};
return next();
}
}
};
(I don’t know if this is a howto question worthy of stackoverflow, apologies)
Is this the right way to handle this in 2.0.0?