I am building a backend in feathers. One of the routes in the API spec is:
/people/{pid}/userData:updatePassword
Is there a way to add this custom action to a people or UserData controller ?
Also is there a way to implement one service which have also it subroutes included. For example: I have a /family
service. I also have a /family/{fid}/members
. Is there a way to include the members
part in the family service ?
HTTP discourages putting actions into the URL and Feathers enforces this a little more strictly than many other frameworks. A good example why actions that modify data shouldn't be done through a GET
request would be a /users/:userid/delete
route where e.g. the Google crawler can come in and wipe your entire site.
To create, modify and remove data is what the POST, PATCH, PUT and DELETE HTTP methods and the respective Feathers service methods .create
, .patch
, .update
and .remove
are for.
So instead of your suggested /people/{pid}/userData:updatePassword
you would do PATCH /people/{pid}
with a { "password": "newPassword" }
JSON body.
To create a route like /family/{fid}/members
you can find more information here, additionally see the FAQ entry on nested routes.