@caviar/plugin-apollo-envdeprecated

Caviar plugin to apply configurations from Ctrip's apollo config service to process.env

Usage no npm install needed!

<script type="module">
  import caviarPluginApolloEnv from 'https://cdn.skypack.dev/@caviar/plugin-apollo-env';
</script>

README

Build Status Coverage

@caviar/plugin-apollo-env

Caviar plugin to apply configurations from Ctrip's apollo config service to process.env

Install

$ npm i @caviar/plugin-apollo-env

Usage

Caviar.config.js

const ApolloEnvPlugin = require('@caviar/plugin-apollo-env')

module.exports = {
  plugins: [
    new ApolloEnvPlugin({
      host: process.env.APOLLO_HOST,
      appId: 'my-app',
      namespace: 'application',
      envs: {
        REDIS_HOST: 'redis.host',

        REDIS_PORT: {
          key: 'redis.port',
          // We can override the default namespace 'application'
          namespace: 'common'
        }
      }
    })
  ],
  ...
}

new ApolloEnvPlugin(options)

  • options Object
    • envs {[string]: string | ConfigOptions} pair of environment variable key and configuration key
    • ...CtripApolloOptions options of ctrip-apollo
interface ConfigOptions {
  // Configuration key name
  key: string

  // options of `ctrip-apollo` which could override the default options
  ...CtripApolloOptions
}

License

MIT