Skip to main content
The @healthzkit/http package provides a HealthAdapter that probes an HTTP or HTTPS endpoint with the global fetch API. Each check records round-trip latency, validates the response status against expectedStatusCodes, and returns ok with metadata.statusCode and metadata.latencyMs on success. Unexpected status codes, timeouts, and transport errors return fail with the caught error. Requires a runtime with global fetch. No peer client package.

Install

Package entrypoints

  • @healthzkit/http — httpAdapter and option types.
  • @healthzkit/http/http — httpAdapter only.
Both resolve to the same factory. Use the subpath when you want a dedicated entry for bundlers.

Shared options

BaseHttpOptions:

httpAdapter

Defaults

Basic readiness check

Authenticated POST probe

Redirects and metadata

Set followRedirects: false to use redirect: "manual" (useful when you need to detect redirects explicitly). Use metadata to read headers or body-related facts from the Response:

Check metadata

Successful checks include the HTTP status alongside any custom metadata hook output:
A non-matching status (for example 503) yields fail with a message like Unexpected status code: 503 Service Unavailable. Request timeouts abort via AbortSignal and return fail with Request timed out after <timeout>ms.

Wiring into createHealthKit

Treat the factory return value as adapter on a check (same as a hand-written { check() { ... } } object):
Combine with schedule on the check if you want cached readiness results instead of calling the upstream on every probe (see Scheduling).