-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure remoting options via app.set
and config.json
#608
Comments
👍 |
@bajtos @raymondfeng unfortunately, |
If I am reading #164 correctly, then you need to set the flag inside {
"remoting": {
"rest": {"normalizeHttpPath": true}
}
} I think it's not necessary to pass the option to https://github.com/strongloop/loopback/blob/master/lib/model.js#L120, because the app-wide setting is IMO used as the default value - see your PR strongloop/strong-remoting#90. |
@bajtos it is already in the |
I see, I guess it is a bug then. I am afraid I don't have enough time to investigate this now myself, sorry for that. I quickly looked at https://github.com/fabien/strong-remoting/blob/7a46b050b8156d1d6ae10e1283f1444da0c52b4d/lib/remote-objects.js#L135-L145, it seems that global options are applied only to classes gathered via |
@fabien Since the option is currently broken, is there a workaround that can force the enabling of |
@mc10 it should work, but I guess it depends on where you declare this setting. Have you tried adding this in your
|
@bajtos yes, this is the issue indeed I think. |
Do I need to add this to each individual model's |
@mc10 I'm afraid this is the only option right now, we need to look in to the issue. You might be able to iterate over all models in a boot script, and set |
I'm not sure how I'd go about iterating through the models individually--would you mind explaining? As a stopgap measure I've used a |
We should rethink what needs to be done here. The current project template loads |
Is there any news regarding the the I changed the
But it has absolutely no effect on the Am I missing something? The first time I reported issues with this was more than a year ago (#1785), was there any progress? |
@sinedied I did a bit of research and found the following: You can enable {
"name": "CartItem",
"base": "PersistedModel",
// ...
"remoting": {
"normalizeHttpPath": true
}
}
{
// ...
"scopes": "object",
"indexes": "object",
"options": {
"type": "object",
"default": {
//---begin addition
"remoting": {
"normalizeHttpPath": false
}
//---end
"validateUpsert": true
} cc @crandmck is the option |
@bajtos Yes, I noticed the only place this flag works was at the module level, but even though it only affect user-added remoting methods, but not methods inherited from PersistedModel. The doc is actually misleading on this option, but it would really be useful to have this option works as described, application-wide to enforce consistency on REST endpoints. As a side note, I find it very ugly that default remoting methods from PersistedModel use a mix of cameCase and kebab-case, that's not very professional when you want to expose a public API :/ |
@sinedied I don't remember all the details about this flag. Could you please create a small app reproducing the issue you are facing per our bug reporting instructions and open a new issue to discuss what's missing in the current implementation of Let's keep this issue #608 focused on what the title says - "Configure remoting options via |
I also think its highly confusing that the documentation states https://loopback.io/doc/en/lb3/config.json.html#top-level-properties
but it doesnt acutally work... |
Yes, if it doesn't actually work as documented, then we should remove doc for @Freundschaft Can you confirm that this is correct? Of course, if/when this is fixed/changed then we should change the docs back accordingly. |
@crandmck at least for me the global settings defintively dont work, i didnt check in the loopback sourcecode though. |
OK, I changed the docs, PTAL ^ |
how can I see the preview of the docs you changed? |
@Freundschaft You can see the changes to the source markdown files in the PR: https://github.com/strongloop/loopback.io/pull/296/files If you want to preview how they will look on when published to the site, follow instructions in http://loopback.io/doc/en/contrib/jekyll_getting_started.html. |
I have managed to address this issue in https://github.com/lehni/strong-remoting/commit/f8ec056509f2fb816e81a00dde440c70fe4e6996 I will create PR for it now on https://github.com/strongloop/strong-remoting |
This is the PR for it: strongloop/strong-remoting#410 |
@lehni Will the above PR require any changes to docs (once it's merged)? |
@crandmck I will look into documentation requirements once the PR landed. I believe that what I found online is actually vague enough that it is not wrong for the new behavior. Bu I just realized that while https://loopback.io/doc/en/lb2/config.json.html Perhaps it's then simply a question of bringing it back? |
I'm sure it was removed for a reason, but if this PR resurrects it, then it's easy enough to reinstate it in the v3 docs. Please advise! |
IIRC, |
|
That's great to hear! These tests should go to strongloop/loopback, to verify our assumptions about how strong-remoting works inside LoopBack apps. You will need to install your development version of strong-remoting into your loopback project, I personally use We already have a test for model-level normalization here, so just add a new test for application-level normalization. |
I think I need some help to get this particular test running. I thought I tracked it down to: grunt karma:unit-once ...or this, if I wanted to run the tests repeatedly while editing them: grunt karma:unit To test things, I then changed this line: request(app).get('/user-accounts').expect(200, done); ...to: request(app).get('/UserAccounts').expect(200, done); ...hoping, it would trigger an error when running the tests again, but it did not. What am I doing wrong? |
Ok, my bad... Turns out it's on the mocha side of things: grunt mochaTest:unit |
Closing as done by strongloop/strong-remoting#410 and #3527. Thank you @lehni for this valuable contribution! 👏 |
So, should I put |
@crandmck yes please! |
@bajtos great news, thank you! |
#433 adds a remoting option
normalizeHttpPath
. At the moment, the only way how to set this options is to modifyserver/server.js
and change the line callingloopback.rest()
.We should modify
loopback.rest()
to read default options viaapp.get()
. Sinceapp.get()
options are already populated fromconfig.json
by loopback-boot, this change will allow developers to keep the configuration in json files.Example configuration in
config.json
:Implementation in
app.handler()
:/cc @fabien @ritch
The text was updated successfully, but these errors were encountered: