agile-config-client
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

在 Midway 中使用

npm i agile-config-client --save
const { Bootstrap } = require('@midwayjs/bootstrap');
const { Agile, config } = require('agile-config-client');

/**
 * http://www.midwayjs.org/docs/env_config
 * 这里的配置有点问题 local 模式下不会运行写入 globalConfig 配置
 */
async function bootstrap() {
    await Agile.configuration({
        // 配置中心 APPID
        appid: process.env.APP_ID,
        // 配置中心 Secret
        secret: process.env.SECRET,
        // 配置中心 NODE 节点 改配置为数组。
        nodes: [
            'node1',
            'node2',
        ],
        // 需要拉取的配置 ENV 环境
        env: process.env.NODE_ENV,
        // name: 'test-service',
        // tag: 'test-service',
        // httptimeout: 3000,
        debug: true,
        // 是否订阅配更新置
        upgrage: false,
        // 订阅连接的心跳包
        // upgrageInterval: 3000,
        // 更新配置成功的回调
        // upgrageCallback: () => { },
    }).bootstrap();
    // 获取配置
    console.log(JSON.stringify(config()));
    // 注入到 Midway JS
    Bootstrap.configure({ globalConfig: config() }).run();
}

bootstrap();

Readme

Keywords

Package Sidebar

Install

npm i agile-config-client

Weekly Downloads

1

Version

1.0.6

License

ISC

Unpacked Size

33.9 kB

Total Files

6

Last publish

Collaborators

  • huaqingyi