[Docs] Jovo Hooks


#1

Middleware hooks are the easiest way to extend certain parts of the Jovo Framework. You can see them as a lightweigt version of Jovo Plugins.


This is a companion discussion topic for the original entry at https://www.jovo.tech/docs/hooks

#2

Can I call app.hook twice for the same middleware name?

app.hook('before.platform.output', (error, host, jovo) => { console.log('a') }
app.hook('before.platform.output', (error, host, jovo) => { console.log('b') }

What I really want to do is move my hook code into separate files, but then I am not sure if the file represents the middleware (only one) or could be different code (possibly more than one app.hook for a middleware).

app.hook('after.platform.init', require('./hooks/logHook.js'));
app.hook('after.platform.init', require('./hooks/anotherHook.js'));

#3

Yes, it’s possible. They are called one after the other.