In FeathersJs I want to not have to remember to add the authenticate hook to my service methods.
I have tried to add the authenticate hook to my app hooks:
function defaultAuthentication() {
return (context: HookContext) => {
return authenticate('jwt')(context);
};
}
app.hooks({
around: {
all: [logError],
},
before: { all: [defaultAuthentication()] },
after: {},
error: {},
});
This successfully adds the authenticate hook to all my methods.
However, I am unable to remove it for specific service methods:
app.use('healthcheck', this);
app.service('healthcheck').hooks({
before: {
all: [],
},
});
This still applies the auth filter to the healthcheck end point.