feat: add GET /api/recommendations/health probe endpoint - #727
Merged
greatest0fallt1me merged 3 commits intoJul 29, 2026
Merged
Conversation
Implements a focused health probe for the recommendations subsystem that reports the status of its two external dependencies (Postgres + Soroban RPC). Changes: - src/routes/recommendations/health.ts: factory-based router with injectable probe callbacks (probeDatabase, probeSorobanRpc), parallel Promise.all execution, correlation ID echo/fallback, structured pino logging, 200/503 HTTP codes. Mirrors the established predictions/health.ts pattern. - src/index.ts: mount recommendationsHealthRouter at /api/recommendations/health (before the general recommendations router to prevent route shadowing). - tests/recommendationsHealth.test.ts: 28 focused tests — HTTP status codes, response shape, correlationId handling, auth access control, error propagation, probe call counts, and default export validation. - docs/recommendations-health.md: runbook covering request/response shape, probe methods, HTTP codes, log events, and security guidance. - README.md: added endpoint row to the Health Endpoints table.
|
@mrteeednut007-dotcom 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
|
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.
feat: add GET /api/recommendations/health probe endpoint
Summary
Implements a focused health probe for the /api/recommendations subsystem that reports the live
status of its two external runtime dependencies. Resolves the GrantFox FWC26 campaign issue.
What changed
function (createRecommendationsHealthRouter) with injectable probe callbacks so tests never
touch real infrastructure. Runs database and sorobanRpc probes in parallel, returns 200 when
both pass and 503 when either fails. Echoes X-Correlation-Id header or generates a UUID
fallback. Emits structured pino log on every request.
placed before the general recommendations router to prevent route shadowing.
response shape, per-dependency latency/error fields, correlation ID echo and fallback, auth
access control (no auth required), error propagation (probe throws → 500), probe call counts,
and default export validation.
codes, structured log events, and security guidance.
Response shape
{
"status": "ok",
"correlationId": "3a6d1f2c-...",
"checkedAt": "2026-07-28T19:27:42.000Z",
"dependencies": {
"database": { "status": "ok", "latencyMs": 4 },
"sorobanRpc": { "status": "ok", "latencyMs": 18 }
}
}
Testing
npm test -- tests/recommendationsHealth.test.ts
28/28 tests pass. No auth required. All external I/O replaced by injectable stubs — no real DB
or network calls in tests.
Checklist
closes Add /api/recommendations/health dependency probe [b#049] #623