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
{{ message }}
Repository navigation
Declaratively load loopback.rest and loopback-explorer #75
@hacksparrow I am afraid your proposal above goes against the original intention of this issue, which is to "Rework the explorer so that it can get the app object via req.app on the first request, in the same way as loopback.rest." I personally think it's a bad practice for middleware to expect the app object in factory arguments, it should get the app it's mounted on via req.app.
However, per the discussion in strongloop/loopback-component-explorer#21, I believe the agreed way forward is to rework loopback-explorer into a component. I'll take a close look on this tomorrow (CEST).
We will now call loopback.rest() directly via a configuration in middleware.json, instead of using server/boot/rest-api.js, and therefore make the necessary changes to loopback/server/middleware/rest.js to enable this, right?
Assuming __dirname is pointing to the same directory where server/middleware.json is, then you can achieve the same result using the following entry in server/middleware.json file:
@bajtos opened a PR to declaratively load loopback.rest - #149. However, there is a bunch of build errors triggered by some pre-existing code, I can fix it if I get the go-ahead. Please review and let me know.
@crandmckcomponent-config.json should parse ${var} too. I have gotten it to parse, but still working on a way for explorer to be loaded declaratively and replicate its current behavior.
With explorer loading as intended, we can close this.
@crandmck as @hacksparrow wrote, we need to land one more change to loopback-boot and then rework the example app to load the explorer component declaratively.
@hacksparrow don't worry about reproducing exactly same behaviour. The important part is to print the explorer URL on start. The support for explorer being an optional dependency can be dropped and explorer can become a proper (required) dependency.
Activity
raymondfeng commentedon Dec 3, 2014
I would also need to access the
appinstance either via the parameter injection or set bybootto the factory/handler instance.9 remaining items
bajtos commentedon Jun 25, 2015
@hacksparrow I am afraid your proposal above goes against the original intention of this issue, which is to "Rework the explorer so that it can get the app object via req.app on the first request, in the same way as loopback.rest." I personally think it's a bad practice for middleware to expect the
appobject in factory arguments, it should get the app it's mounted on viareq.app.However, per the discussion in strongloop/loopback-component-explorer#21, I believe the agreed way forward is to rework loopback-explorer into a component. I'll take a close look on this tomorrow (CEST).
hacksparrow commentedon Jun 25, 2015
Thanks for the feedback @bajtos, will change accordingly.
hacksparrow commentedon Jul 16, 2015
@bajtos per this example:
We will now call
loopback.rest()directly via a configuration inmiddleware.json, instead of usingserver/boot/rest-api.js, and therefore make the necessary changes toloopback/server/middleware/rest.jsto enable this, right?bajtos commentedon Aug 5, 2015
Yes please.
I am not aware of any changes that are necessary, could you please elaborate little bit more?
bajtos commentedon Aug 5, 2015
Did you mean implementing necessary changes to support
"paths": ["${restApiRoot}"]? That should be implemented in loopback-boot'slib/executor.jshacksparrow commentedon Aug 12, 2015
Thanks for the info @bajtos.
Another thing; what would be the interface for doing something like this?
bajtos commentedon Aug 12, 2015
Assuming
__dirnameis pointing to the same directory whereserver/middleware.jsonis, then you can achieve the same result using the following entry inserver/middleware.jsonfile:{ "files": { "loopback#static": { "params": "$!../client" } } }hacksparrow commentedon Aug 13, 2015
@bajtos opened a PR to declaratively load loopback.rest - #149. However, there is a bunch of build errors triggered by some pre-existing code, I can fix it if I get the go-ahead. Please review and let me know.
hacksparrow commentedon Aug 13, 2015
Also, are we not supporting
constyet?hacksparrow commentedon Aug 13, 2015
@bajtos is there a reason why loopback#rest takes an array of paths while loopback-explorer takes a single
mountPath?crandmck commentedon Aug 26, 2015
@bajtos Can this be closed with the merging of #149?
If not, what are the remaining items to complete before this can be closed?
hacksparrow commentedon Aug 27, 2015
@crandmck
component-config.jsonshould parse${var}too. I have gotten it to parse, but still working on a way for explorer to be loaded declaratively and replicate its current behavior.With explorer loading as intended, we can close this.
bajtos commentedon Aug 27, 2015
@crandmck as @hacksparrow wrote, we need to land one more change to loopback-boot and then rework the example app to load the explorer component declaratively.
@hacksparrow don't worry about reproducing exactly same behaviour. The important part is to print the explorer URL on start. The support for explorer being an optional dependency can be dropped and explorer can become a proper (required) dependency.
hacksparrow commentedon Sep 5, 2015
@bajtos @crandmck I guess we can close this now?