To add custom methods today one would probably do
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.
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 (https://github.com/feathersjs/feathers/issues/488#issuecomment-269687714) 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?).
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!
I've created a plugin, which lets you add custom methods to services: https://www.npmjs.com/package/feathers-custom-methods
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.
Most helpful comment
I've created a plugin, which lets you add custom methods to services: https://www.npmjs.com/package/feathers-custom-methods