loopback icon indicating copy to clipboard operation
loopback copied to clipboard

disableRemoteMethod does not work in boot script

Open jmimi opened this issue 10 years ago • 7 comments

/server/boot/initializer.js

app.models.Foo.disableRemoteMethod("find", true);

Above code doest not affect anything.

jmimi avatar Dec 09 '15 12:12 jmimi

@jmimi I was trying to reproduce your issue, it seems like the method still shows up in the API explorer, but the call to the method itself does become 404 Not found for me. Is this also your case? Or your endpoint is still call-able.

davidcheung avatar Dec 09 '15 21:12 davidcheung

@davidcheung I forgot what is exactly the case. But I'm sure disableRemoteMethod should be call in model definition

jmimi avatar Dec 14 '15 11:12 jmimi

@jmimi I'm trying to see if this could be a bug with the remote layer, so we can identify where the issue is coming from, and when I was trying to reproduce the call becomes 404 when I run

app.models.Foo.disableRemoteMethod("find", true);

But the method still appears in the explorer for me.

disableRemoteMethod does get called, and makes function uncallable, not unviewable,

But I'm sure disableRemoteMethod should be call in model definition

@bajtos would you know what the intented behavior is? should we grey out the method in API-explorer or to Hide it completely?

davidcheung avatar Dec 17 '15 20:12 davidcheung

@davidcheung Why there is different behaviour between calling in boot-script and model-definition?

jmimi avatar Dec 17 '15 23:12 jmimi

disableRemoteMethod does get called, and makes function uncallable, not unviewable

This is expected. We don't have a mechanism to notify loopback-component-explorer that a method was disabled.

A similar case is adding a new model after explorer was initialised. To address that, we modified loopback to emit an event when a new model is added to the app, and now there is a pending patch https://github.com/strongloop/loopback-component-explorer/pull/141 to listen for that event in explorer.

I think we should do the same for remote methods.

@davidcheung I think the triage is done here and the issue can be labelled as "feature" + "Beginner friendly".

bajtos avatar Dec 18 '15 07:12 bajtos

I have submitted 2 PRs to solve this issue (#2266 and strongloop/loopback-component-explorer#157).

supasate avatar Apr 27 '16 20:04 supasate

@bajtos This issue was solved. You can close this issue.

supasate avatar Jul 12 '16 14:07 supasate