Skip to content

Latest commit

 

History

History
65 lines (49 loc) · 1.65 KB

README.md

File metadata and controls

65 lines (49 loc) · 1.65 KB

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