th: sure. why not. let's interpolate DB_HOST.

lolsob-rspec
kouhai dev 2023-10-21 21:10:34 -07:00
parent e60d9bed75
commit 276954bfd0
1 changed files with 6 additions and 0 deletions

View File

@ -94,6 +94,12 @@ const parseJSON = (json, req) => {
* @returns {Object.<string, any>} the configuration for the PostgreSQL connection * @returns {Object.<string, any>} the configuration for the PostgreSQL connection
*/ */
const pgConfigFromEnv = (env) => { const pgConfigFromEnv = (env) => {
if (env.DB_HOST) {
env.DB_HOST = env.DB_HOST.replaceAll(/\$\w+|\$\{\w+\}/g, (match) => {
const name = match.startsWith('${') ? match.slice(2, -1) : match.slice(1);
return env[name];
});
}
const pgConfigs = { const pgConfigs = {
development: { development: {
user: env.DB_USER || pg.defaults.user, user: env.DB_USER || pg.defaults.user,