feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
14.97k stars 742 forks source link

Custom Service Routes beyond CRUD (without using X-Service-Method) #3422

Closed dustinc closed 5 months ago

dustinc commented 5 months ago

I am loving Dove so far, but am running into a kind of major roadblock while attempting something super simple.

The project is an existing REST API that I am converting from Express (JS) to Feathers (TS) w/ a switch to Koa. I prefer Koa anyways. I have a resource Gig that does most of the heavy lifting. There are many endpoints beyond basic CRUD operations e.g. GET /gigs/requests/pending (gets all pending requests for all gigs for admin users to see), GET /gigs/:id/requests (gets all requests for specific gig), POST /gigs/:id/confirm (lets user confirm their gig) and so on. In Express and Koa you simple stack your routes in order to prevent "not an id" error, but you're free to add whatever routes you wish.

I've read about Custom Service Method and was only able to find a solution that, for me, would equate to POST /gigs with header X-Service-Method=xxxx. This may be fine for greenfield projects (I've never used this approach before in a REST API), but I would like to make this transition with minimal to zero impact on the mobile app that is consuming this API.

Why is this so difficult to achieve in Feathers Dove? I really really really want to continue using Dove, but I cannot seem to find any resources regarding a solution, and I would prefer not to hack in something. What is the "feathers" way to solve this fairly basic problem?

Hopefully I am just missing something really simple that someone can point out to me. (feel free to point and laugh afterwards 😄, I'll welcome it!)

Please help!! Thank you.