Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atian25/egg-remote-config
workaround for egg remote config
https://github.com/atian25/egg-remote-config
egg egg-plugin eggjs
Last synced: about 1 month ago
JSON representation
workaround for egg remote config
- Host: GitHub
- URL: https://github.com/atian25/egg-remote-config
- Owner: atian25
- License: mit
- Created: 2020-07-23T02:14:13.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-08-27T01:28:54.000Z (over 3 years ago)
- Last Synced: 2024-11-01T09:51:36.623Z (about 1 month ago)
- Topics: egg, egg-plugin, eggjs
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 22
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-egg - egg-remote-config - workaround for egg remote config ![](https://img.shields.io/github/stars/atian25/egg-remote-config.svg?style=social&label=Star) ![](https://img.shields.io/npm/dm/egg-remote-config.svg?style=flat-square) (仓库 / 插件)
README
# egg-remote-config
[![NPM version][npm-image]][npm-url]
[![Node.js CI][action-image]][action-url]
[![Test coverage][codecov-image]][codecov-url][npm-image]: https://img.shields.io/npm/v/egg-remote-config.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-remote-config
[action-image]: https://github.com/atian25/egg-remote-config/workflows/Node.js%20CI/badge.svg
[action-url]: https://github.com/atian25/egg-remote-config/actions?query=workflow%3A%22Node.js+CI%22
[codecov-image]: https://codecov.io/gh/atian25/egg-remote-config/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/atian25/egg-remote-configWorkaround for egg remote config.
Because Egg Config Loader is sync, but sometime we need to load remote config.
So, this plugin will load remote config at agent's lifecycle, then write to file, then readFileSync at worker's lifecycle.
## Install
```bash
$ npm i --save egg-remote-config
```## Usage
```js
// {app_root}/config/plugin.js
exports.remoteConfig = {
enable: true,
package: 'egg-remote-config',
};
```## Configuration
```js
// {app_root}/config/config.default.js
exports.remoteConfig = {
async handler(agent) {
// will override app.config
const { data } = await agent.curl('http://remote-url/config', { dataType: 'json', contentType: 'json' });
return data;
}
};
```see [config/config.default.js](config/config.default.js) for more detail.
## Example
## Questions & Suggestions
Please open an issue [here](https://github.com/atian25/egg-remote-config/issues).
## License
[MIT](LICENSE)