0.0.1 • Published 8 months ago

ezconfig-client v0.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

在 Midway 中使用

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

/**
 * http://www.midwayjs.org/docs/env_config
 * 这里的配置有点问题 local 模式下不会运行写入 globalConfig 配置
 */
async function bootstrap() {
    await EZConfig.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();
0.0.1

8 months ago

1.0.2

8 months ago

1.0.1

10 months ago

1.0.0

10 months ago