A middleware is a function that accepts the next handler in the chain and returns a new handler that wraps it.
const timing: Middleware = (next) => async (url, init) => { const start = performance.now(); const res = await next(url, init); console.log(`${url} took ${performance.now() - start}ms`); return res;}; Copy
const timing: Middleware = (next) => async (url, init) => { const start = performance.now(); const res = await next(url, init); console.log(`${url} took ${performance.now() - start}ms`); return res;};
A middleware is a function that accepts the next handler in the chain and returns a new handler that wraps it.