3.0.0 • Published 5 years ago

@caviar/ctrip-apollo-env-plugin v3.0.0

Weekly downloads
114
License
MIT
Repository
github
Last release
5 years ago

Build Status Coverage

@caviar/ctrip-apollo-env-plugin

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.

Install

$ npm i @caviar/ctrip-apollo-env-plugin

Usage

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'
          }
        }
      })
    ],
    ...
  },
  ...
}

new ApolloEnvPlugin(options)

  • options Object
    • keys {[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