-
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 I've read about Custom Service Method and was only able to find a solution that, for me, would equate to POST 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. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
You can create any route structure you need with placeholders and custom services. In this case e.g. class GigConfirmService {
constructor(app) {
this.app = app
}
async create (data, params) {
const gigId = params.route.id
return this.app.service('gigs').patch(gigId, { status: 'confirmed' })
}
}
class GigRequestService {
constructor(app) {
this.app = app
}
async find (params) {
const gigId = params.route.id
return this.app.service('gigs').find({
query: { gigId }
})
}
}
app.use('gigs/:id/confirm', new GigConfirmService(app))
app.use('gigs/:id/requests', new GigRequestService(app)) How service methods map to HTTP methods is documented in the REST API client docs. |
Beta Was this translation helpful? Give feedback.
-
@daffl Thank you so much for your response; I will try this out right now. It does feel strange creating a new service for specific endpoints on the same resource. I was really hoping to map a custom route to a custom service method all within the same resource-specific service. Thank you! |
Beta Was this translation helpful? Give feedback.
You can create any route structure you need with placeholders and custom services. In this case e.g.
How service methods map to HTTP methods is documented i…