Skip to content

feat(frontend): configure the Postgres pool from the environment - #183

Merged
thewealthyplace merged 1 commit into
prism-explorer:mainfrom
codexhange:fix/issue-38-postgres-pool-env
Oct 22, 2026
Merged

thewealthyplace merged 1 commit into
prism-explorer:mainfrom
codexhange:fix/issue-38-postgres-pool-env

Conversation

@codexhange

@codexhange codexhange commented Oct 22, 2026 •

Copy link
Copy Markdown

Summary

getPool built the pg Pool from DATABASE_URL alone, so pool size, idle timeout and TLS could not be configured and the frontend could not talk to a managed Postgres that requires TLS.

The pool is now built by poolConfigFromEnv from:

Variable Default Meaning
DATABASE_POOL_MAX 10 Maximum pooled connections
DATABASE_IDLE_TIMEOUT_MS 10000 Close idle connections after this long
DATABASE_SSL false true verifies the server certificate, no-verify encrypts without verifying (for providers whose CA is not in Node's trust store)

Defaults are pg's own values, so deployments that set nothing behave exactly as before. Invalid values fail on first use with a clear error instead of being silently ignored or silently disabling TLS. All three are documented in .env.example and passed through the compose frontend service, which now also accepts DATABASE_URL so it can be pointed at a managed instance.

Checks

  • npx tsc --noEmit — no errors in the touched files (the repo's pre-existing errors in src/app/** and unrelated tests are unchanged)
  • npm run lint on the touched files
  • npm test — the new poolConfigFromEnv tests pass (7); the suite's other failures are pre-existing on main
  • npm run build — fails on main for pre-existing type errors; not attempted here

I also probed the real wire behaviour against a local TCP server: DATABASE_SSL=true and no-verify make pg send an SSLRequest, while the default sends a plain startup packet.

Notes

frontend/src/lib/indexed-db.test.ts previously imported getLatestValues, getKeyHistory and getKeysByPrefix, which the module no longer exports, so the file could never pass. I replaced it with tests for the new pool config rather than leaving a dead test file next to the feature.

Closes #38
closes #36
closes #39
closes #16

The pool was built from DATABASE_URL alone, so a deployment could not raise
its size, tune the idle timeout, or enable TLS for a managed Postgres. Read
DATABASE_POOL_MAX, DATABASE_IDLE_TIMEOUT_MS and DATABASE_SSL instead, keeping
pg's current values (10 connections, 10s idle, no TLS) as defaults and failing
on invalid values rather than silently ignoring them.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@drips-wave

drips-wave Bot commented Oct 22, 2026

Copy link
Copy Markdown

@codexhange 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! 🚀

Learn more about application limits

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

@luciusverus-cyber is attempting to deploy a commit to the thewealthyplace100-8633's projects Team on Vercel.

A member of the Team first needs to authorize it.

@thewealthyplace
thewealthyplace merged commit 40cf35f into prism-explorer:main Oct 22, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants