I need to implement a bunch of routes that do very custom / complex operations on a FeathersJS app.
One of those routes is /Category/disableExclusiveContentsOf
You can still implement the route using your own service and use the :id
as route parameter:
app.use('/Category/disableExclusiveContentsOf/:id', {
find() {
// do complex stuff here
}
});
One thing I'd recommend changing is that the URL seems to be action and not resource oriented. This means that someone can change your application data with a GET request which is generally considered not a good practise (e.g. in some cases the Google crawler came in and deleted/changed a bunch of things).
Feathers encourages you to think in resources rather than custom routes and actions. In your case you would have an ExclusiveContents
service that you can POST
to:
app.use('/Category/ExclusiveContents/:categoryId', {
create(data, params) {
// do complex stuff here
params.categoryId // the id of the category
data // -> additional data from the POST request
}
});