0

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.

4

1 回答 1

2

这些钩子的作用是寻找params.provider被设置。未设置的任何内容params.provider都被视为内部调用。如果您想将其他参数传递给内部调用,您可以例如_.omit属性provider

app.service('/api/internal/helper').find(omit(context.params, 'provider'))
于 2019-02-06T23:32:35.057 回答