feat: enhance configuration with database connection settings and pool tuning#104
Merged
greatest0fallt1me merged 2 commits intoCalloraOrg:mainfrom Feb 26, 2026
Merged
Conversation
Contributor
|
LGTM! |
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
/api/healthto reflect database connectivity (ok vs degraded).DATABASE_URLand pool tuning environment variables.Details
Config & pooling
configto include:databaseUrl(fromDATABASE_URL, with a local default).dbPooloptions derived from env vars:DB_POOL_MAXDB_IDLE_TIMEOUT_MSDB_CONN_TIMEOUT_MSdb.tsto:pg.Poolusing the centralized config.query(text, params?)helper for simple one-off queries.checkDbHealth()which executesSELECT 1and returns{ ok, error? }, logging failures if the DB is unavailable.Health endpoint
HealthResponseintypes/index.tsto:status: 'ok' | 'degraded'.dbobject:{ status: 'ok' | 'error', error?: string }./api/health(router) to:checkDbHealth()on each request.status: "ok"when the DB is reachable.status: "degraded"anddb.status: "error"(with error message) when the DB is down or misconfigured.Environment documentation
.env.exampledocumenting:PORT,NODE_ENV.DATABASE_URLwith an example that matchesdocker-composeand a local default.DB_POOL_MAX,DB_IDLE_TIMEOUT_MS,DB_CONN_TIMEOUT_MS.Configuration
Required
DATABASE_URLmust point to a reachable PostgreSQL instance.Optional
DB_POOL_MAX– max clients in pool (default:10).DB_IDLE_TIMEOUT_MS– idle client lifetime in ms (default:30000).DB_CONN_TIMEOUT_MS– acquire timeout in ms (default:2000).Test Plan
Health with DB up
docker-compose up).DATABASE_URL.GET /api/health→200with:status: "ok"db: { status: "ok" }Health with DB down
DATABASE_URLat an unavailable host.GET /api/health→200with:status: "degraded"db: { status: "error", error: "<message>" }closes Set Up PostgreSQL and Connection Pool #6
Closes Add Wallet Authentication (Stellar Address Verification) #18
Closes Add Vault Balance Check Middleware (Pre-Call) #23
Closes Add REST Route: List Public APIs (Marketplace) #27