📌 Description
src/db/index.ts creates the pg pool but doesn't expose its utilization (active/idle/waiting connection counts), making it hard to diagnose connection-pool exhaustion from src/routes/diagnostics.ts or logs.
🧩 Requirements and context
- Export a function from
src/db/index.ts that reads the pool's current totalCount/idleCount/waitingCount.
- Surface these stats from
src/routes/diagnostics.ts.
- No change to pool behavior, purely observability.
🛠️ Suggested execution
- Add a
getPoolStats() export in src/db/index.ts.
- Call it from the diagnostics handler and include the stats in the response.
- Add a test asserting the stats reflect actual pool state (e.g. after acquiring a client).
✅ Acceptance criteria
🔒 Security notes
None — this is read-only observability, ensure it doesn't expose connection strings.
📋 Guidelines
- Minimum 95% test coverage
- Clear documentation
- Timeframe: 96 hours
📌 Description
src/db/index.tscreates thepgpool but doesn't expose its utilization (active/idle/waiting connection counts), making it hard to diagnose connection-pool exhaustion fromsrc/routes/diagnostics.tsor logs.🧩 Requirements and context
src/db/index.tsthat reads the pool's currenttotalCount/idleCount/waitingCount.src/routes/diagnostics.ts.🛠️ Suggested execution
getPoolStats()export insrc/db/index.ts.✅ Acceptance criteria
getPoolStats()returns accurate active/idle/waiting counts.🔒 Security notes
None — this is read-only observability, ensure it doesn't expose connection strings.
📋 Guidelines