Skip to content
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

Feature request: Generic service method #714

Closed
arve0 opened this issue Nov 1, 2017 · 4 comments
Closed

Feature request: Generic service method #714

arve0 opened this issue Nov 1, 2017 · 4 comments

Comments

@arve0
Copy link
Contributor

arve0 commented Nov 1, 2017

To add custom methods today one would probably do

  1. create an express middleware and communicate directly over http on client, or
  2. (mis?)use the create method.

For example, see authentication-management, where they use this pattern:

app.service('authManagement').create({
  type: 'specialMethod',
  data...
})

Earlier, custom methods has been rejected #86, according to @daffl "for several good reasons". In the stack exchange answer, the link for the detailed explanation is broken, so I might have missed some good points.

Anyway, if not custom methods, I believe there is room for a generic method. Like service.post, that works over both REST and socket.

@daffl
Copy link
Member

daffl commented Nov 2, 2017

The FAQ entry can be found here: https://docs.feathersjs.com/faq/readme.html#how-do-i-create-custom-methods and the linked issue comment (#488 (comment)) has more details on this.

I never needed it but if there really is a need for custom actions, implementing a custom service with a create method seems fine to me. app.service('action').create makes more sense to me than app.service('action').post (what does post even mean outside of HTTP?).

@arve0
Copy link
Contributor Author

arve0 commented Nov 2, 2017

Thank you for links to earlier discussions, they have some very good points!

One point I think is not mentioned before is ease of understanding, for beginners. For example the authentication create and remove hooks. What does it really mean to "create an authentication"? That confuses me as a beginner. I've read the guide from beginning, and honestly forgot or misunderstood the impact of feathers being a REST only framework.

I never needed it but if there really is a need for custom actions

I assume you have needed authentication, e.g. app.authenticate, which I see as a custom action. It's implemented with service.create, so I'm splitting hairs 😅

makes more sense to me than app.service('action').post (what does post even mean outside of HTTP?).

Post was just a suggestion, and I mean post in the sense "publish something". Though the connection to HTTP POST might be confusing. action, do and method will work just as fine.

As I understand you and the earlier discussions, this is definitely outside bounds, as a feathers is strictly a REST architecture. So I'm closing. Thanks for answering!

@arve0 arve0 closed this as completed Nov 2, 2017
@arve0
Copy link
Contributor Author

arve0 commented Nov 7, 2017

I've created a plugin, which lets you add custom methods to services: https://www.npmjs.com/package/feathers-custom-methods

@lock
Copy link

lock bot commented Feb 7, 2019

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.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants