Is your feature request related to a problem? Please describe.
Today _spartan only allows you to directly access environment variables if NODE_ENV !== 'production'. The application should accommodate scenarios in which different environment variable files can be accessed depending on the named environment
Describe the solution you'd like
On calling fetchSecret(variable):
_spartan checks process.env.NODE_ENV
run this case:
if (process.env.NODE_ENV === 'production'){
require('dotenv').config({ path: '/full/custom/path/to/your/env/prod_vars' })
return process.env[variable]
} else if (process.env.NODE_ENV === 'development'){
require('dotenv').config({ path: '/full/custom/path/to/your/env/dev_vars' })
return process.env[variable]
} else if (process.env.NODE_ENV === 'stage'){
require('dotenv').config({ path: '/full/custom/path/to/your/env/stage_vars' })
return process.env[variable]
}
... // have a case for each of the environments
else {
let error = new Error ('secrets/no-matching-env')
return error
}
**Why does this feature belong in \_spartan?**
Ensures that _all_ secrets stored as environment variables can be loaded safely regardless of environment type and encourages developers to _not_ keep these in source code
**Describe alternatives you've considered**
N/A
**Additional context**
Add any other context or screenshots about the feature request here.
Is your feature request related to a problem? Please describe. Today _spartan only allows you to directly access environment variables if NODE_ENV !== 'production'. The application should accommodate scenarios in which different environment variable files can be accessed depending on the named environment
Describe the solution you'd like On calling
fetchSecret(variable)
:process.env.NODE_ENV
else { let error = new Error ('secrets/no-matching-env') return error }