Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/caviarjs/ctrip-apollo-env-plugin

Caviar plugin to apply configurations from Ctrip's apollo config service to process.env
https://github.com/caviarjs/ctrip-apollo-env-plugin

caviar caviar-plugin ctrip-apollo

Last synced: 4 days ago
JSON representation

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

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.org/caviarjs/ctrip-apollo-env-plugin.svg?branch=master)](https://travis-ci.org/caviarjs/ctrip-apollo-env-plugin)
[![Coverage](https://codecov.io/gh/caviarjs/ctrip-apollo-env-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/caviarjs/ctrip-apollo-env-plugin)

# @caviar/ctrip-apollo-env-plugin

[Caviar](https://github.com/caviarjs/caviar) plugin to apply configurations from Ctrip's [apollo](https://github.com/ctripcorp/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

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

## Usage

Caviar.config.js

```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`](https://github.com/kaelzhang/ctrip-apollo)

```ts
interface ConfigOptions {
// Configuration key name
key: string

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

## License

MIT