egg-apollojs-no-schedule
v0.1.6
Published
apollo plugin for egg.js & support hot patch
Downloads
2
Readme
egg-apollojs-no-schedule
Install
$ npm i egg-apollojs-no-schedule --save
Usage
// {app_root}/config/plugin.js
exports.apollojs = {
enable: true,
package: 'egg-apollojs-no-schedule',
};
Configuration
// {app_root}/config/apollo.js
module.exports = {
configServerUrl: process.env.configServerUrl,
appId: 'node-test-1', // 配置中心命名和项目名称保持一致,
clusterName: 'default',
namespaceName: ['application', 'python.PostgreSQL', 'python.redis', 'python.ops'], // 两个namespace相同配置,application配置会覆盖'python.mysql'
};
// {app_root}/preload.js
// 初始化env并存贮
require('egg-apollojs-no-schedule').init(__dirname + '/config/apollo.js');
// package.json
// 配置不同的configServerUrl 对应不同的环境
// 开发环境
"dev": "configServerUrl=http://127.0.0.1:8084 node preload.js && configServerUrl=http://127.0.0.1:8084 egg-bin dev"
// 执行npm start 之前设置apollo地址环境变量: configServerUrl=http://127.0.0.1:8084 npm start
//部署环境
"start":"node preload.js && eggctl start"
// {app_root}/config/config.default.js
'use strict';
// 加载process.env
require('egg-apollojs-no-schedule').apollo.setEnv();
module.exports = appInfo => {
const config = {};
config.test1 = process.env.test1;
}
Example
Questions & Suggestions
Please open an issue here.