feat: add /api/health/dependencies probes#455
Merged
greatest0fallt1me merged 1 commit intoJul 25, 2026
Conversation
Add GET /api/health/dependencies endpoint. - src/routes/health/dependencies.ts — factory createDependenciesRouter() with injectable ProbeFn for full testability; mirrors the pattern of health/ready.ts - 200/207/503 driven by composite status (ok/degraded/down) - x-correlation-id header echoed; UUID generated when absent - Structured pino logging on every request - src/index.ts — mounts the router at /api/health/dependencies - tests/healthDependencies.test.ts — 25 tests: status codes (6), response body shape (7), correlationId (4), auth (2), error handling (2), default export (1) - docs/health-dependencies.md — full API runbook Lint: clean Tests: 25 passed, 25 total Closes Predictify-org#301
|
@ValJnr-dev1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Perfect. LGTM ✨ merging now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements #301 — dependency health probes at
/api/health/dependencies.What was added
GET /api/health/dependenciesProbes all four external dependencies in parallel and returns a per-system snapshot.
200ok)207degraded, nonedown503downResponse shape:
{ "status": "ok", "correlationId": "<uuid>", "checkedAt": "2026-07-24T22:00:00.000Z", "dependencies": { "postgres": { "status": "ok", "latencyMs": 3 }, "sorobanRpc": { "status": "ok", "latencyMs": 12 }, "horizon": { "status": "ok", "latencyMs": 8 }, "webhookQueue": { "status": "ok", "latencyMs": 1 } } }Files changed
src/routes/health/dependencies.tscreateDependenciesRouter({ probeFn })src/index.ts/api/health/dependenciestests/healthDependencies.test.tsdocs/health-dependencies.mdDesign notes
probeFn— all external I/O is encapsulated in the injected function, making the route fully testable without real infrastructure (same pattern ashealth/ready.ts)./healthz/dependencies, this endpoint always runs a fresh probe. Callers that want caching can usegetCachedDependencyHealth()directly.health_dependencies_check_completepino log line with correlationId, composite status, per-probe status, and elapsed ms.Test output
Lint: ✅ clean (
eslint src/**/*.tsexit 0)Closes #301