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

This commit is contained in:
Kouhai 2023-10-21 21:10:34 -07:00
parent e60d9bed75
commit 276954bfd0

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,