feat(database): add getConnectionString method#652
Conversation
📝 WalkthroughSummary by CodeRabbitRelease Notes
WalkthroughA new Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/database/prod/src/main.ts (1)
39-48: Consider using this helper insidegetDatabase()to avoid logic drift.Line 40 to Line 47 now duplicates connection-string resolution/validation logic that also exists in
getDatabase(). WiringgetDatabase()through this helper for the env path would keep a single source of truth.♻️ Suggested refactor
export function getDatabase(options: GetDatabaseOptions = {}): DatabaseConnection { - const env = getEnvironment() - const connectionString = options.connectionString ?? env.get('NETLIFY_DB_URL') - - if (!connectionString) { - throw new MissingDatabaseConnectionError() - } + const env = getEnvironment() + const connectionString = options.connectionString ?? getConnectionString()🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/database/prod/src/main.ts` around lines 39 - 48, The connection-string resolution in getDatabase() is duplicated; refactor getDatabase() to call the existing getConnectionString() helper instead of re-reading the env or duplicating validation. Update getDatabase() to use getEnvironment() only inside getConnectionString(), remove any NETLIFY_DB_URL lookup/throw in getDatabase(), and ensure MissingDatabaseConnectionError remains the single failure path so all callers rely on getConnectionString() for the env.get('NETLIFY_DB_URL') logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/database/prod/src/main.ts`:
- Around line 39-48: The connection-string resolution in getDatabase() is
duplicated; refactor getDatabase() to call the existing getConnectionString()
helper instead of re-reading the env or duplicating validation. Update
getDatabase() to use getEnvironment() only inside getConnectionString(), remove
any NETLIFY_DB_URL lookup/throw in getDatabase(), and ensure
MissingDatabaseConnectionError remains the single failure path so all callers
rely on getConnectionString() for the env.get('NETLIFY_DB_URL') logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8b97063b-9eed-4789-b67b-12459485d113
📒 Files selected for processing (2)
packages/database/prod/src/main.test.tspackages/database/prod/src/main.ts
No description provided.