From 8593b5e4df898b698ab2a6d34da0853492fe1b7b Mon Sep 17 00:00:00 2001 From: imechoim Date: Wed, 10 Jan 2024 11:58:30 +0100 Subject: [PATCH] Add postgres env vars (#54) --- src/utils/utils.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index b66d89a9..9e6f808d 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -299,6 +299,18 @@ export class Utils { const pgPassword = pgRdsConfig.password; const pgUsername = pgRdsConfig.username; dsnList = `postgres://${pgUsername}:${pgPassword}@${pgHost}:${pgPort}/${pgDb}?ssl=true`; + } else if ( + process.env.POSTGRES_HOSTS && + process.env.POSTGRES_PORT && + process.env.POSTGRES_USER_PASSWD && + process.env.POSTGRES_USER_NAME && + process.env.POSTGRES_DB_NAME + ) { + dsnList = process.env.POSTGRES_HOSTS.split(',') + .map((host) => { + return `postgres://${process.env.POSTGRES_USER_NAME}:${process.env.POSTGRES_USER_PASSWD}@${host}:${process.env.POSTGRES_PORT}/${process.env.POSTGRES_DB_NAME}?ssl=true`; + }) + .join(','); } else { dsnList = process.env.POSTGRES_DSN_LIST; }