监控:本地建立工具时的一些配置

This commit is contained in:
luying
2021-04-29 18:42:48 +08:00
parent a383dfc73f
commit c55be393a9
4 changed files with 76 additions and 1 deletions

View File

@@ -0,0 +1,67 @@
import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg';
const path = require('path');
export default (appInfo: EggAppInfo) => {
const config = {} as PowerPartial<EggAppConfig>;
// override config from framework / plugin
// use for cookie sign key, should change to your own and keep security
config.keys = appInfo.name + '_1597499383757_3508';
config.security = {
csrf: {
enable: false,
},
domainWhiteList: [ '*' ],
};
config.cors = {
origin: '*', // 匹配规则 域名+端口 *则为全匹配
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
};
// add your egg config in here
config.middleware = [ 'parmsDecode' ];
config.mongoose = {
url: 'mongodb://127.0.0.1/zyz', // 内网
options: { useNewUrlParser: true, useUnifiedTopology: true },
};
config.alinode = {
appid: '86043',
secret: '54ef0364995b0c4f2ab42150e29ad30df8327a3a',
error_log: [ '${appInfo.root}/logs/${appInfo.name}/zyz-web.log', '${appInfo.root}/logs/${appInfo.name}/common-error.log', '${appInfo.root}/logs/${appInfo.name}/egg-agent.log' ],
packages: [ '${appInfo.baseDir}/package.json' ],
};
config.xtransit = {
server: 'ws://127.0.0.1:9092',
appId: 1,
appSecret: '6b7b40d3787d9f041b0f9d2688c28631'
};
config.view = {
root: path.join(appInfo.baseDir, '/app/public'),
defaultViewEngine: 'nunjucks',
mapping: {
'.html': 'nunjucks' //左边写成.html后缀会自动渲染.html文件
},
};
config.decodeParm = false;
config.static = {
prefix: '/',
dir: path.join(appInfo.baseDir, '/app/public'),
};
// add your special config in here
const bizConfig = {
sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`,
};
// the return config will combines to EggAppConfig
return {
...config,
...bizConfig,
};
};

View File

@@ -15,6 +15,10 @@ const plugin: EggPlugin = {
enable: true,
package: 'egg-alinode',
},
xtransit: {
enable: true,
package: 'egg-xtransit',
}
};
export default plugin;

View File

@@ -22,7 +22,8 @@
"clean": "ets clean",
"local": "cross-env EGG_SERVER_ENV=local npm run dev",
"isbn": "cross-env EGG_SERVER_ENV=isbn npm run dev",
"monitor": "cross-env EGG_SERVER_ENV=monitor npm run dev"
"monitor": "cross-env EGG_SERVER_ENV=monitor npm run dev",
"lylocal": "cross-env EGG_SERVER_ENV=lylocal npm run dev"
},
"dependencies": {
"cross-env": "^7.0.3",
@@ -32,6 +33,7 @@
"egg-cors": "^2.2.3",
"egg-scripts": "^2.6.0",
"egg-view-nunjucks": "^2.2.0",
"egg-xtransit": "^1.2.2",
"mongoose-transactions": "^1.1.4",
"reflect-metadata": "^0.1.13",
"request": "^2.88.2",

View File

@@ -17,6 +17,7 @@ import 'egg-view';
import 'egg-view-nunjucks';
import 'egg-cors';
import 'egg-alinode';
import 'egg-xtransit';
import { EggPluginItem } from 'egg';
declare module 'egg' {
interface EggPlugin {
@@ -35,5 +36,6 @@ declare module 'egg' {
nunjucks?: EggPluginItem;
cors?: EggPluginItem;
alinode?: EggPluginItem;
xtransit?: EggPluginItem;
}
}