Defines a middleware function with type inference.
A convenience helper that ensures the provided handler conforms to the
MiddlewareFn signature while preserving exact parameter and
return types. This allows TypeScript to infer narrower types for
TParameters and TReturn without needing explicit generic annotations
on the handler.
Use this when defining middleware functions to get accurate type checking
and IntelliSense without sacrificing type safety.
Type Parameters
TParameters extends unknown[] = unknown[]
Type of arguments passed through the middleware chain
Defines a middleware function with type inference.
A convenience helper that ensures the provided handler conforms to the MiddlewareFn signature while preserving exact parameter and return types. This allows TypeScript to infer narrower types for
TParametersandTReturnwithout needing explicit generic annotations on the handler.Use this when defining middleware functions to get accurate type checking and IntelliSense without sacrificing type safety.