Skip to content

docs(health): document all health endpoint response fields and states#575

Merged
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
Ajibose:feat/health-check-docs
Jul 19, 2026
Merged

docs(health): document all health endpoint response fields and states#575
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
Ajibose:feat/health-check-docs

Conversation

@Ajibose

@Ajibose Ajibose commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Closes #571

Summary

  • Expands docs/health-endpoints.md with complete field-by-field documentation for all four health endpoints: liveness (/health), readiness (/health/ready), diagnostics (/health/detailed), and indexer heartbeat (/health/indexer)
  • Defines healthy / degraded / unhealthy states and allowed values for every field
  • Explains the liveness vs readiness distinction with a comparison table
  • Documents the exact non-200 trigger condition for each endpoint
  • Adds health.response-schema.test.ts — 70 tests that act as a living contract between the code and the documentation
  • Fixes a pre-existing setHeader is not a function bug in two existing test files that caused 6 tests to fail on main

New files

  • src/modules/health/health.response-schema.test.ts — response field schema tests for all four health endpoints

Modified files

  • docs/health-endpoints.md — expanded from partial docs to complete endpoint reference
  • src/modules/health/health.controllers.test.ts — added res.setHeader stub to mockResponse helper (fixes 6 pre-existing failures)
  • src/modules/health/health.controllers.integration.test.ts — same setHeader fix

Implementation details

Documentation (docs/health-endpoints.md)

The updated doc covers:

Endpoint Non-200 trigger
GET /health (liveness) Never — always 200
GET /health/ready (readiness) ready: false when any check is "fail" → 503
GET /health/detailed (diagnostics) database.status === "disconnected" in production → 503
GET /health/indexer (worker heartbeat) data.status === "degraded" → 503

Each endpoint section includes: response shape example, field table with types and descriptions, state tables mapping field values to conditions, and the precise non-200 trigger condition.

The liveness vs readiness distinction is explained in a comparison table at the top of the document.

Tests (health.response-schema.test.ts)

Tests are organised by endpoint and state. Key coverage:

  • Liveness — response shape, field types, always-200 contract
  • Readiness (healthy) — all checks pass, field types, per-check latencyMs
  • Readiness (degraded) — 503 on any failure, ready: false as trigger, error string present, latencyMs still present at top level
  • Detailed (DB connected) — all top-level fields, memory, system, timeouts, database, syncing computation, services array values
  • Detailed (DB disconnected, non-production) — 200 still returned, database.status: "disconnected", no responseTime, Database service "unhealthy"
  • Indexer heartbeat — all three status states (unknown, healthy, degraded) with HTTP code, lastSuccessfulRun, and staleSinceMs assertions
  • Heartbeat record — response shape on POST /health/indexer/heartbeat

How to test

# Run only health module tests
pnpm exec jest src/modules/health/ --no-coverage

# Expected: 91 tests passed across 4 suites

Expands docs/health-endpoints.md to cover every response field for all
four health endpoints (liveness, readiness, detailed, indexer heartbeat)
with healthy/degraded/unhealthy values, liveness vs readiness distinction,
and explicit non-200 trigger conditions per endpoint.

Adds health.response-schema.test.ts with 70 tests that act as a living
contract between the code and the documentation, covering field types,
allowed enum values, and HTTP status mapping for every documented state.

Fixes pre-existing setHeader TypeError in health.controllers.test.ts and
health.controllers.integration.test.ts that caused 6 tests to fail.
@Ajibose
Ajibose force-pushed the feat/health-check-docs branch from 1728b7e to 9a0c809 Compare July 18, 2026 15:04
@Chucks1093
Chucks1093 merged commit ad42a42 into accesslayerorg:main Jul 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add docs for server health check endpoint response fields and what each indicates

2 participants