How to add a new service on top of an existing path

36 Views Asked by At

I'm trying to build a service whose path I wanted to extend from an existing path. Here's my scenario. I have one service called instances which has, among others, the path /instances/<id>/ which can retrieve information about an instance. I want to add a new service for fetching screenshot of the instance. And I wanted it to be on the path: /instances/<id>/screenshot. But as you know on feathersjs, creating a new service registers it on its own path, in this case /screenshot.

Is it possible to do what I intended ? Having the new service on top of the existing? I might be using the wrong terms here, but I need the screenshot endpoint to access the <id> of the instances endpoint.

I tried creating the service, but it gets registered on its own path, which means if I have to access the instance id, I would probably pass it as a query param. My requirement was to have the instance id passed on the path.

1

There are 1 best solutions below

0
Daff On

You can do what you are looking for by registering the service on a path of instances/:instanceId/screenshot. The instance id will then be available in params.route as params.route.instanceId.