• Setup liveness and readiness probe endpoints on a predefined port. The result will contain two objects liveness & readiness which can be used to set the appropriate values depending on the service state.

    By default, an http server will be started listening on port 9000. The liveness will be accessible via the path /live and will be set to true. The readiness will be accessible via the path /ready and will be set to false. The readiness will need to be set to true once the service is considered ready to be serving requests.

    Following HTTP status codes along with the messages will be returned based on the liveness & readiness state values.

    Liveness:

    TRUE  - HTTP 200, `SERVICE_IS_RUNNING`
    FALSE - HTTP 503, `SERVICE_IS_UNAVAILABLE`

    Readiness:

    TRUE  - HTTP 200, `SERVICE_IS_READY`
    FALSE - HTTP 503, `SERVICE_IS_NOT_READY`

    Parameters

    • config: ValueObject<{
          environment: (() => "test" | "development" | "production");
          fullDevLogs: (() => boolean);
          healthEndpointPort: (() => number);
          isDev: (() => boolean);
          isProd: (() => boolean);
          logLevel: (() => "" | "FATAL" | "ERROR" | "WARN" | "INFO" | "DEBUG" | "TRACE");
          logMaskKeywords: (() => string[]);
          logMaskMaxDepth: (() => number);
          secureLoggingMode: (() => MaskMode);
          serviceId: (() => string);
      }>

      A service config object.

    • livenessReadinessOptions: ILivenessReadinessOptions = {}

      The configuration object for liveness & readiness endpoints

    • Optional logger: Logger

      A logger object to use for output generated inside the middleware.

    Returns {
        liveness: State<boolean>;
        readiness: State<boolean>;
    }

    • liveness: State<boolean>
    • readiness: State<boolean>

Generated using TypeDoc