Skip to content

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

License

Notifications You must be signed in to change notification settings

caviarjs/ctrip-apollo-env-plugin

Repository files navigation

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published