feathersjs / hooks

Async middleware for JavaScript and TypeScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to remove a hook?

mikeconley12 opened this issue · comments

For example, I have the following:

const { hooks } = require('@feathersjs/hooks');

const logRuntime = async (context, next) => {
	// ...
}

class Hello {
  async sayHi (name) {
    return `Hi ${name}`
  }
}

hooks(Hello, {
  sayHi: [
    logRuntime
  ]
});

How do I remove the logRuntime hook?

There is no official way to remove a hook.

The easiest in this case is to run the hook conditionally with https://hooks-common.feathersjs.com/hooks.html#iff

Thank you for the answer