-
-
Notifications
You must be signed in to change notification settings - Fork 752
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
Allow different names and endpoints for services... #691
Comments
The path that you add in To avoid confusion in the future the best solution is probably to remove the |
I'm sure you said what you meant and but just to clarify here's what I'm hearing :-)
:-) Which is all fine and I am happy to help. But to be clear in case I wasn't, I was proposing a change to exactly what you pointed out is the case now:
That this be relaxed so that path and name could be separated (with path as the default) to encourage reuse. Was that the PR you were asking for? I'd hate to begin something that wasn't agreed to. Regards, |
P.s. sorry - I see I wasn't explicit enough about sequelize - that's generating my Model :-o |
I'm not saying is bunk, I would say I'm not sure I understand the use case. If we want different service names for different applications we just
If you want to alias the an existing service under a different name you can also do |
Good ideas - I'll try right away. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs. |
The CLI’s service generator for a Sequelize services adds a ‘name’ property to the options it passes to the service constructor.
However in this help page the 'name' option is never mentioned: https://docs.feathersjs.com/api/databases/sequelize.html#api .
I’ve looked and stepped through the service() code and in fact it doesn’t seem to be used. Instead the leading slash is stripped off the service endpoint “/items” and into a variable location and the remaining part of the endpoint is also used as the service name.
I thought the changing the line like so app.use('/restaurants', createService({name: 'item', Model, paginate} ) would allow me to mount the service on any url but it turns out that throws this error at launch:
Proposed:
It would be great if the service name could actually be set by an option or argument such that a common service name and its code could be reused in multiple apps/projects and only the service's route changed.
Use case:
A reusable service "items" provides the same CRUD implementation (fields, computed fields, custom processing etc) for an "item" but each app that requires/includes the service could have the route be specific to its type/client in that particular app (/restaurants, /groceries, /movies, /todo etc ).
Notes:
not sure: perhaps rename the service by doing find/replace in the services[] array as long as the service's actual route isn't ret-conned from location in turn.
or perhaps vice versa: create service "items" first and then overwrite the endpoint with '/restaurants'. Issue Unregistering services and hooks #446 implies that maybe can only do in REST - because of needing to unbind from transports. So this might not be an option.
Related:
This is a similar thing: using Sequelize I'm able to have an actual DB table name be different than whatever I call the JS model by modifying the generated code. But that doesn't apply to the service's options.name field
issue Unregistering services and hooks #446 also talks about unregistering services after they're live but was removed from Buzzard. And I'm not looking for hot swapping, just intelligent options during setup
The text was updated successfully, but these errors were encountered: