- remove unused config files - load all server env variables from ./config/env - still define PWD as midwest seems to be using it
31 lines
584 B
JavaScript
31 lines
584 B
JavaScript
'use strict'
|
|
|
|
function readFromEnv(columns, defaults) {
|
|
const missing = []
|
|
|
|
const result = columns.reduce((result, variable) => {
|
|
const value = (result[variable] = process.env[variable] || defaults[variable])
|
|
|
|
if (!value) {
|
|
missing.push(variable)
|
|
}
|
|
|
|
return result
|
|
}, {})
|
|
|
|
if (missing.length) {
|
|
throw new Error(`Missing required env variables: ${missing.join(', ')}`)
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
const defaults = {
|
|
NODE_ENV: 'development',
|
|
POSTGRES_HOST: 'localhost',
|
|
}
|
|
|
|
module.exports = {
|
|
...readFromEnv(['NODE_ENV', 'POSTGRES_HOST'], defaults),
|
|
}
|