I want to use internally defined services in hooks added to public REST endpoints, is this possible?
By internally defined I'm referring to using the disallow hook from feathers-common-hooks.
app.service('/api/internal/helper').hooks( { before: { all: disallow('rest') } } )
The hook looks at the provider
in the context
object, if it matches what I've disabled. I.e if disallow('rest') is used then it disables the service from being accessed from REST.
The problem is I want to use this internal helper
service in a hook that is attached to a public service, but haven't found a way to do so. When the internal service is called the provider
is still rest and the call is blocked.
What those hooks do is look for params.provider being set. Anything where params.provider
is not set is considered an internal call. If you want to pass other params along to the internal call you can e.g. _.omit the provider
property:
app.service('/api/internal/helper').find(omit(context.params, 'provider'))