Skip to main content Link Search Menu Expand Document (external link)

Middlewares overview

Mechanism for extendning behaviour of all handlers on the server.

Added in v1.0.0


Table of contents


logging

accessLog

Add access logs for handled requests. The log runs before each request. Optionally configure log level using the first argument. The default log level is Debug.

Signature

export declare const accessLog: (
  level?: LogLevel.LogLevel
) => <R, E>(app: HttpApp.Default<E, R>) => HttpApp.Default<E, R>

Added in v1.0.0

errorLog

Logs out a handler failure.

Signature

export declare const errorLog: <R, E>(app: HttpApp.Default<E, R>) => HttpApp.Default<E, R>

Added in v1.0.0

uuidLogAnnotation

Annotate request logs using generated UUID. The default annotation key is requestId. The annotation key is configurable using the first argument.

Note that in order to apply the annotation also for access logging, you should make sure the accessLog middleware is plugged after the uuidLogAnnotation.

Signature

export declare const uuidLogAnnotation: (
  logAnnotationKey?: string
) => <R, E>(app: HttpApp.Default<E, R>) => HttpApp.Default<E, R>

Added in v1.0.0