Middleware function type with next() pattern.
Middleware can:
Environment type
Route parameters type
Data type for middleware-set data
const timingMiddleware: Middleware = async (ctx, next) => { const start = Date.now(); const response = await next(); ctx.log.info(`Request took ${Date.now() - start}ms`); return response;}; Copy
const timingMiddleware: Middleware = async (ctx, next) => { const start = Date.now(); const response = await next(); ctx.log.info(`Request took ${Date.now() - start}ms`); return response;};
Middleware function type with next() pattern.
Middleware can: