Caviar plugin to apply configurations from Ctrip's apollo config service to process.env
.
@caviar/ctrip-apollo-env-plugin
is a caviar sandbox plugin which means it only works if caviar sandbox is used.
$ npm i @caviar/ctrip-apollo-env-plugin
Caviar.config.js
const ApolloEnvPlugin = require('@caviar/ctrip-apollo-env-plugin')
module.exports = {
caviar: {
plugins: [
new ApolloEnvPlugin({
host: process.env.APOLLO_HOST,
appId: 'my-app',
namespace: 'application',
keys: {
REDIS_HOST: 'redis.host',
REDIS_PORT: {
key: 'redis.port',
// We can override the default namespace 'application'
namespace: 'common'
}
}
})
],
...
},
...
}
- options
Object
- keys
{[string]: string | ConfigOptions}
pair of environment variable key and configuration key - ...CtripApolloOptions options of
ctrip-apollo
- keys
interface ConfigOptions {
// Configuration key name
key: string
// options of `ctrip-apollo` which could override the default options
...CtripApolloOptions
}
MIT