function createHttpIndicator
Since 0.2.0
createHttpIndicator(
name: string,
): IHealthIndicator

Creates an HTTP probe indicator.

This indicator performs an HTTP GET request to the specified URL and reports 'up' if the response status is 2xx or 3xx, 'down' otherwise. The request is aborted after timeoutMs via the web-standard AbortSignal.timeout, so the indicator needs no runtime services and can be constructed at app-registration time. Per-indicator latency is measured by the health service, not here.

The fetcher option allows injecting a custom fetch implementation for testing purposes.

Examples

Example 1

const indicator = createHttpIndicator('external-api', {
  url: 'https://api.example.com/health',
  timeoutMs: 3000,
});
app.register(HealthPlugin({
  indicators: [indicator],
}));

Parameters

name: string

Indicator name

Configuration options

Return Type

An indicator that probes an HTTP endpoint

Usage

import { createHttpIndicator } from "health-plugin/src/index.ts";