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: 10 months 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 (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-08-27T01:28:54.000Z (over 4 years ago)
- Last Synced: 2025-05-16T11:39:50.783Z (12 months ago)
- Topics: egg, egg-plugin, eggjs
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 23
- Watchers: 1
- 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   (仓库 / 插件)
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-config
Workaround 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)