Setu-TS
    Preparing search index...

    Type Alias MiddlewareFunction

    MiddlewareFunction: (
        ctx: IRequestContext,
        next: NextFunction,
    ) => void | HandlerResult | Promise<void | HandlerResult>

    A middleware function: pre-process, call next(), post-process. May short-circuit by returning a response without calling next().

    Type Declaration

    const timing: MiddlewareFunction = async (ctx, next) => {
    const runtime = ctx.services.get<IRuntimeServices>(CAPABILITIES.RUNTIME);
    await next();
    // ctx.startTime is a monotonic runtime.hrtime() reading; subtract it from
    // another monotonic reading — never from a wall-clock epoch.
    ctx.response.header('X-Duration', String(runtime.hrtime() - ctx.startTime));
    };

    0.1.0