exframe-Configuration
Setup
Use the environment variable CONFIG_STORE to set the configuration mode. The default is 'env', available is 'env' and 'vault'
CONFIG_STORE = 'ENV'
The configuration module will look for the variables in process.env.
CONFIG_STORE = 'VAULT'
The configuration module will look for the variables by using configuration files located at /vault/secrets. Each secret is saved in a separate file and read independently, if secret is not found, uses default value Environment variable names are used to match the file name required
API Reference
get(key)
(Promise) Gets a value in the configuration server ####Returns: JSON object value for the key ####Throws:
- Error Exception
Param | Type |
---|---|
key | string |
secret(key)
Get a value directly from the secret ####Returns: object value
Example
const config = require('exframe-configuration');
config.get('bb')
.then((response) => {
console.log('success', response);
})
.catch((err) => {
console.log('error', err);
});
// OUTPUT: success { TEST: 'TESTVALUE' }
const config = require('exframe-configuration');
var result = config.secret('mongo_url')
// OUTPUT: TESTVALUE
Example
const configModule = require('exframe-configuration').config;
const bbVal = configModule.default.bb;
// OUTPUT: success { bb: 'TESTVALUE' }