egg-remote-config

1.0.1 • Public • Published

egg-remote-config

NPM version Node.js CI Test coverage

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

$ npm i --save egg-remote-config

Usage

// {app_root}/config/plugin.js
exports.remoteConfig = {
  enable: true,
  package: 'egg-remote-config',
};

Configuration

// {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 for more detail.

Example

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i egg-remote-config

Weekly Downloads

37

Version

1.0.1

License

MIT

Unpacked Size

6.93 kB

Total Files

7

Last publish

Collaborators

  • atian25