import * as Response from './response' ; export type Middleware < Request , Result , Response extends Response . Generic > = ( req : Request ) => MiddlewareOutput < Result , Response > | Promise < MiddlewareOutput < Result , Response > > ; export type Generic < Request > = Middleware < Request , any , Response . Generic > ; export type MiddlewareOutput < Result , Response > = MiddlewareResult < Result > | MiddlewareResponse < Response > ; export type MiddlewareResult < Result > = { value : Result ; finalizer ? : MiddlewareFinalizer ; } ; export type MiddlewareFinalizer = ( ) => void | Promise < void > ; export type MiddlewareResponse < Response > = { response : Response ; } ; export function next ( ) ; export function next < Result > ( value , finalizer ? ) ; export function next ( value ? , finalizer ? ) { return { value , finalizer } ; } export function stop < Response extends Response . Generic > ( response ) { return { response } ; }