How to Write Custom Middlewares


#1

There are examples of how to create hooks for Jovo-supplied middlewares.

I am wondering if it is possile to create your own middlewares (either stand-alone or as part of a plugin) that an app developer (or developers using your plugin) could then take advantage of?

What are some examples of what you can do with custom middlewares?

@AlexSwe


#2

What are the differences/benefits to using middleware vs hooks?

app.middleware('after.platform.init').use((handleRequest) => { 
  // handleRequest.jovo 
  console.log('middleware');
});

VS.

app.hook('after.platform.init', (error, host, jovo) => {
  // jovo 
  console.log('hook');
});