You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@raymondfeng I'd like to discuss this before we go and implement the injection. The canonical express way of accessing the app object is to use req.app from within the handler function. We are already doing this in loopback.rest().
What is so special about your middleware that it needs the app object outside of the handler function?
On the second thought, middleware factory should not setup models nor register other middleware. Instead, we should implement a new mechanism to support complex components like oauth2.
The component exports function(app, options), end-user configures components in a new file (component-config.json?) and loopback-boot will invoke the functions exported by configured components.
This is most likely the item/feature that should have been implemented as part of #45.
Activity
bajtos commentedon Dec 10, 2014
@raymondfeng I'd like to discuss this before we go and implement the injection. The canonical express way of accessing the
appobject is to usereq.appfrom within the handler function. We are already doing this in loopback.rest().What is so special about your middleware that it needs the app object outside of the handler function?
bajtos commentedon Dec 17, 2014
Looking at oauth2-loopback.js, the component needs the
appobject for two tasks:Further inspection of models/index reveals following usage:
loopbackto callloopback.getModelByTypeto auto-detectUserandApplicationmodels to useapp.dataSources[name]I would prefer to improve the middleware-registration process to support all three cases listed above instead of injecting the
appobject.bajtos commentedon Jan 5, 2015
On the second thought, middleware factory should not setup models nor register other middleware. Instead, we should implement a new mechanism to support complex components like oauth2.
The component exports
function(app, options), end-user configures components in a new file (component-config.json?) and loopback-boot will invoke the functions exported by configured components.This is most likely the item/feature that should have been implemented as part of #45.