-
Notifications
You must be signed in to change notification settings - Fork 449
feat: load connection string from env var #8142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,17 @@ interface RawDBConnection { | |
| } | ||
|
|
||
| export async function connectRawClient(buildDir: string): Promise<RawDBConnection> { | ||
| const envConnectionString = process.env.NETLIFY_DB_URL | ||
| if (envConnectionString) { | ||
| const client = new Client({ connectionString: envConnectionString }) | ||
| await client.connect() | ||
| return { | ||
| client, | ||
| connectionString: envConnectionString, | ||
| cleanup: () => client.end(), | ||
|
Comment on lines
+32
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prevent raw At Line 34, returning Proposed direction export async function connectRawClient(buildDir: string): Promise<RawDBConnection> {
const envConnectionString = process.env.NETLIFY_DB_URL
if (envConnectionString) {
const client = new Client({ connectionString: envConnectionString })
await client.connect()
return {
client,
- connectionString: envConnectionString,
+ connectionString: redactConnectionString(envConnectionString),
cleanup: () => client.end(),
}
}// Add near this module (or shared util)
const redactConnectionString = (value: string): string => {
try {
const url = new URL(value)
if (url.password) url.password = '***'
if (url.username) url.username = '***'
return url.toString()
} catch {
return '[redacted]'
}
}🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
|
|
||
| const state = new LocalState(buildDir) | ||
| const storedConnectionString = state.get('dbConnectionString') | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.