1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
| import { EggAppConfig, EggAppInfo, PowerPartial } from "egg";
|
| exports.alinode = {
| server: "wss://agentserver.node.aliyun.com:8081",
| appid: "81900",
| secret: "25acfb7a1e3aac1a22ccbffcdc4db9ec67f38d98",
| logdir: "/tmp/",
| error_log: ["/root/.logs/error.#YYYY#-#MM#-#DD#.log"]
| };
|
| export default (appInfo: EggAppInfo) => {
| const config = {} as PowerPartial<EggAppConfig>;
|
| // WCS中间件url地址
| config.domainUrl = "http://localhost:8733";
| // 是否模拟返回成功
| config.isVirtual = true;
| // config.domainUrl = "http://192.168.43.189:8733";
| // config.domainUrl = "http://10.103.11.253:8733";
|
| // override config from framework / plugin
| // use for cookie sign key, should change to your own and keep security
| config.keys = appInfo.name + "_1557052425333_9912";
|
| // add your egg config in here
| config.middleware = ["origin", "apiCheckAuth", "compress"];
| config.origin = {
| whiteList: ["*"]
| };
|
| // 配置compress
| config.compress = {
| threshold: 2048 // 超过2048B进行压缩,不写默认为1024B
| };
|
| config.apiCheckAuth = {
| // 跳过的路由,路由都小写
| actions: [
| "/api/open/idcardadd", // 客户端api推送身份证
| "/api/auth/gettoken", // 获取token
| "/api/auth/login", // 系统用户登录
| "/api/auth/logOut", // 系统用户登出 【Editby shaocx,2024-03-20】
| "/api/auth/loginuser", // 用户登录
| "/api/auth/updateApp", // 更新App
| //"/api/common/uploadsinglefile", // 单文件上传 //西门子已通知 上传和下载 功能无权限限制 【Editby shaocx,2024-03-20】
| "/api/task/redisinitproduct", // 物料信息redis初始化
| //"/api/common/download", // 通用文件下载 //西门子已通知 上传和下载 功能无权限限制 【Editby shaocx,2024-03-20】
| "/download/*",
| "/api/tms/usersys/client/*", //客户端
| "/api/user/getnewsinfo",
| "/api/auth/getvalidatecode", //获取验证码
| "/api/sys/user/saaSModifyPwd", //修改SaaS超级管理员密码
| "/api/task/*", // 任务调度
| "/api/tms/userSys/claim/*", // 微信端索赔
| "/api/tms/userSys/weixin/*", // 微信公众号
| "/api/auod/pda/*", // PDA
| "/api/sys/basicInfo/*" // 系统信息
| ]
| };
| // 配置指定的前端地址
| config.cors = {
| origin: "http://127.0.0.1:7001",
| allowMethods: "GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS",
| // 下面这条加上才能共享跨域session,同时前端ajax请求也要加上响应的参数
| credentials: true
| };
| config.security = {
| csrf: {
| enable: false
| },
| // 白名单
| domainWhiteList: ["*"]
| };
|
| // 文件上传类型
| config.multipart = {
| whitelist: [
| ".jpg",
| ".jpeg", // image/jpeg
| ".png", // image/png, image/x-png
| ".gif", // image/gif
| ".bmp", // image/bmp
| ".txt",
| ".zip",
| ".gz",
| ".tgz",
| ".gzip",
| ".xlsx",
| ".docx"
| ]
| };
|
| config.redis = {
| app: true,
| clients: {
| product: {
| port: 6379, // Redis port
| host: "localhost", // Redis host
| password: "redis123",
| db: 0
| },
| fenjianji: {
| port: 6379, // Redis port
| host: "localhost", // Redis host
| password: "redis123",
| db: 1
| },
| userInfo: {
| port: 6379,
| host: "localhost",
| password: "redis123",
| db: 2
| },
| common: {
| port: 6379,
| host: "localhost",
| password: "redis123",
| db: 3
| }
| }
| };
|
| // config.mongodb = {
| // app: true,
| // agent: false,
| // default: {
| // hosts: "127.0.0.1:27017",
| // ip: "127.0.0.1",
| // port: 27017,
| // username: "dev",
| // password: "dev#yrt123",
| // db: "dev",
| // query: ""
| // },
| // client: {
| // hosts: "127.0.0.1:27017",
| // ip: "127.0.0.1",
| // port: 27017,
| // username: "dev",
| // password: "dev#yrt123",
| // db: "dev",
| // query: ""
| // }
| // };
|
| config.bodyParser = {
| jsonLimit: "5mb",
| formLimit: "6mb",
| enableTypes: ["json", "form", "text"],
| extendTypes: {
| text: ["text/xml", "application/xml"]
| }
| };
| // add your special config in here
| const bizConfig = {
| sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`,
| // 开启日志
| openLog: false
| };
|
| // 新增自定义日志
| config.customLogger = {
| // 作业任务自定义日志
| taskLogger: {
| file: `${appInfo.root}/logs/${appInfo.name}/taskLogger.log`,
| formatter(meta) {
| return `[${meta.date}] ${meta.message}`;
| },
| // ctx logger
| contextFormatter(meta) {
| return `[${meta.date}] [${meta.ctx.method}] ${meta.message}`;
| }
| },
| scheduleLogger: {
| file: `${appInfo.root}/logs/${appInfo.name}/scheduleLogger.log`,
| formatter(meta) {
| return `[${meta.date}] ${meta.message}`;
| },
| contextFormatter(meta) {
| return `[${meta.date}] [${meta.ctx.method}] ${meta.message}`;
| }
| }
| };
|
| // the return config will combines to EggAppConfig
| return {
| ...config,
| ...bizConfig
| };
| };
|
|