Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/caviarjs/ctrip-apollo-env-plugin
- Owner: caviarjs
- License: other
- Created: 2019-04-05T11:51:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-05T06:42:31.000Z (about 5 years ago)
- Last Synced: 2024-11-07T01:16:42.412Z (7 days ago)
- Topics: caviar, caviar-plugin, ctrip-apollo
- Language: JavaScript
- Homepage:
- Size: 34.2 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE
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