Skip to content

Commit

Permalink
fix: broken mongodb connection (#343)
Browse files Browse the repository at this point in the history
Closes #342
  • Loading branch information
andrew-codes authored Jun 3, 2024
1 parent 4eecf83 commit 86e4a55
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const computeUrl = (
connectionOptions?: DbConnectionOptions | DbConnectionString,
): string => {
if (!connectionOptions) {
return `mongodb://localhost:27017`
return `mongodb://${process.env.DB_HOST ?? 'localhost'}:27017`
}
if ('url' in connectionOptions) {
return connectionOptions.url
Expand All @@ -39,8 +39,8 @@ const getDbClient = (

if (!client) {
const url = computeUrl(connectionOptions)
const username = connectionOptions?.username
const password = connectionOptions?.password
const username = connectionOptions?.username ?? process.env.DB_USERNAME
const password = connectionOptions?.password ?? process.env.DB_PASSWORD

debug(`Existing DB client not found; creating one with the provided URL`)
if (!username && !password) {
Expand Down

0 comments on commit 86e4a55

Please sign in to comment.