Docs
Concepts
Middleware

Middleware

A middleware is a function that takes a handler, does something to it (e.g. adds headers) and returns this changed handler back.

type Middleware = Handler => Handler

Given the type above, we can stack middlewares one on another i.e.

const handler = middleware1(middleware2(middleware3(handler0)))