2018-10-30

Compose express middlewares

Function composition is a great tool, to allow to create a more isolated function with clear responsibility and single purpose. Function composition allows combining these functions to create a more complex one.

This pattern can also be used to express middlewares. This allows having more isolated middlewares, easier to test. And to expose a composed middleware that can guarantee that a middleware is going to be called after another one.