Closed fratzinger closed 1 year ago
This PR adds a first implementation for custom methods.
As of now, my custom methods behave like other regular method. I have a sum method for which I need the find permissions to apply. So I use options.method to 'overwrite' context.method.
sum
find
options.method
context.method
Example:
class CustomService extends MemoryService { sum(data: any, params: any) { return this.find(params); } } app.use("tests", new CustomService({ ... }), { methods: ["find", "get", "create", "update", "patch", "remove", "sum"], }) const service = app.service("tests"); service.hooks({ before: { sum: [ authorize({ method: "find", adapter: "@feathersjs/memory", }), ], }, after: { sum: [ authorize({ method: "find", adapter: "@feathersjs/memory", }), ], }, }); const items = (await service.sum(null, { ability: defineAbility( (can) => { can("read", "tests", { userId: 1 }); }, { resolveAction } ), paginate: false, }));
This PR adds a first implementation for custom methods.
As of now, my custom methods behave like other regular method. I have a
sum
method for which I need thefind
permissions to apply. So I useoptions.method
to 'overwrite'context.method
.Example: