HttpHealthIndicator

The HTTPHealthIndicator contains health indicators which are used for health checks related to HTTP requests

  
class HttpHealthIndicator extends HealthIndicator {
  pingCheck(key: string, url: string, __2: AxiosRequestConfig & { httpClient?: HttpClientLike; } = {}): Promise<HealthIndicatorResult>
  responseCheck<T>(key: string, url: string | URL, callback: (response: AxiosResponse<T>) => boolean | Promise<boolean>, __3: AxiosRequestConfig & { httpClient?: HttpClientLike; } = {}): Promise<HealthIndicatorResult>

  // inherited from terminus/lib/HealthIndicator
  protected getStatus(key: string, isHealthy: boolean, data?: { [key: string]: any; }): HealthIndicatorResult
}

Methods

pingCheck()

Checks if the given url response in the given timeout and returns a result object corresponding to the result


pingCheck(key: string, url: string, __2: AxiosRequestConfig & { httpClient?: HttpClientLike; } = {}): Promise<HealthIndicatorResult>

Parameters

Option Type Description
key string

The key which will be used for the result object

url string

The url which should be request

__2 AxiosRequestConfig & { httpClient?: HttpClientLike; }

Optional. Default is {}.

Examples

    
httpHealthIndicator.pingCheck('google', 'https://google.com', { timeout: 800 })

Returns

Promise<HealthIndicatorResult>

Throws

HealthCheckError In case the health indicator failed

responseCheck()


responseCheck<T>(key: string, url: string | URL, callback: (response: AxiosResponse<T>) => boolean | Promise<boolean>, __3: AxiosRequestConfig & { httpClient?: HttpClientLike; } = {}): Promise<HealthIndicatorResult>

Parameters

Option Type Description
key string
url string | URL
callback (response: AxiosResponse) => boolean | Promise
__3 AxiosRequestConfig & { httpClient?: HttpClientLike; }

Optional. Default is {}.

Returns

Promise<HealthIndicatorResult>