ee-core 1.2.7-beta.2 → 1.2.7-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +2 -2
- package/bin/tools.js +22 -22
- package/config/config.default.js +247 -247
- package/core/index.js +12 -12
- package/core/lib/ee.js +209 -209
- package/core/lib/loader/context_loader.js +105 -105
- package/core/lib/loader/ee_loader.js +451 -451
- package/core/lib/loader/file_loader.js +262 -262
- package/core/lib/loader/mixin/config.js +138 -138
- package/core/lib/loader/mixin/controller.js +123 -123
- package/core/lib/loader/mixin/service.js +29 -29
- package/core/lib/utils/base_context_class.js +34 -34
- package/core/lib/utils/index.js +100 -100
- package/core/lib/utils/sequencify.js +59 -59
- package/core/lib/utils/timing.js +77 -77
- package/index.js +49 -49
- package/lib/appLoader.js +45 -45
- package/lib/application.js +80 -80
- package/lib/baseApp.js +118 -118
- package/lib/constant.js +28 -28
- package/lib/eeApp.js +326 -326
- package/lib/helper.js +51 -51
- package/lib/httpclient.js +136 -136
- package/lib/logger.js +46 -46
- package/lib/socket/httpServer.js +104 -104
- package/lib/socket/io.js +23 -23
- package/lib/socket/ipcServer.js +128 -128
- package/lib/socket/socketClient.js +50 -50
- package/lib/socket/socketServer.js +76 -76
- package/lib/socket/start.js +22 -22
- package/lib/storage/appStorage.js +13 -13
- package/lib/storage/index.js +21 -21
- package/lib/storage/lowdbStorage.js +143 -143
- package/package.json +45 -45
- package/resource/loading.html +21 -21
- package/resource/view_example.html +21 -21
- package/tools/codeCompress.js +204 -204
- package/tools/replaceDist.js +76 -76
- package/utils/common.js +30 -30
- package/utils/index.js +206 -202
- package/utils/wrap.js +37 -37
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 Wallace Gao
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Wallace Gao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
# ee-core
|
|
2
|
-
ee core
|
|
1
|
+
# ee-core
|
|
2
|
+
ee core
|
package/bin/tools.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const codeCompress = require('../tools/codeCompress');
|
|
4
|
-
const replaceDist = require('../tools/replaceDist');
|
|
5
|
-
|
|
6
|
-
// argv
|
|
7
|
-
const args = process.argv;
|
|
8
|
-
// console.log('[ee-core] args:', args);
|
|
9
|
-
const cmd = args[2];
|
|
10
|
-
console.log('[ee-core] cmd:', cmd);
|
|
11
|
-
|
|
12
|
-
if (cmd == 'rd') {
|
|
13
|
-
replaceDist.run();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (cmd == 'compress') {
|
|
17
|
-
codeCompress.compress();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (cmd == 'restore') {
|
|
21
|
-
codeCompress.restore();
|
|
22
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const codeCompress = require('../tools/codeCompress');
|
|
4
|
+
const replaceDist = require('../tools/replaceDist');
|
|
5
|
+
|
|
6
|
+
// argv
|
|
7
|
+
const args = process.argv;
|
|
8
|
+
// console.log('[ee-core] args:', args);
|
|
9
|
+
const cmd = args[2];
|
|
10
|
+
console.log('[ee-core] cmd:', cmd);
|
|
11
|
+
|
|
12
|
+
if (cmd == 'rd') {
|
|
13
|
+
replaceDist.run();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (cmd == 'compress') {
|
|
17
|
+
codeCompress.compress();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (cmd == 'restore') {
|
|
21
|
+
codeCompress.restore();
|
|
22
|
+
}
|
package/config/config.default.js
CHANGED
|
@@ -1,247 +1,247 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The configuration of ee application, can be access by `app.config`
|
|
6
|
-
* @class Config
|
|
7
|
-
* @since 1.0.0
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
module.exports = appInfo => {
|
|
11
|
-
|
|
12
|
-
const config = {
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The environment of ee
|
|
16
|
-
* @member {String} Config#env
|
|
17
|
-
* @see {appInfo#env}
|
|
18
|
-
* @since 1.0.0
|
|
19
|
-
*/
|
|
20
|
-
env: appInfo.env,
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The name of the application
|
|
24
|
-
* @member {String} Config#name
|
|
25
|
-
* @see {appInfo#name}
|
|
26
|
-
* @since 1.0.0
|
|
27
|
-
*/
|
|
28
|
-
name: appInfo.name,
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The current directory of the application
|
|
32
|
-
* @member {String} Config#baseDir
|
|
33
|
-
* @see {appInfo#baseDir}
|
|
34
|
-
* @since 1.0.0
|
|
35
|
-
*/
|
|
36
|
-
baseDir: appInfo.baseDir,
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* The current HOME directory
|
|
40
|
-
* @member {String} Config#HOME
|
|
41
|
-
* @see {appInfo#HOME}
|
|
42
|
-
* @since 1.0.0
|
|
43
|
-
*/
|
|
44
|
-
HOME: appInfo.home,
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* The directory of server running. You can find `application_config.json` under it that is dumpped from `app.config`.
|
|
48
|
-
* @member {String} Config#rundir
|
|
49
|
-
* @default
|
|
50
|
-
* @since 1.0.0
|
|
51
|
-
*/
|
|
52
|
-
rundir: path.join(appInfo.baseDir, 'run'),
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* dump config
|
|
56
|
-
*
|
|
57
|
-
* It will ignore special keys when dumpConfig
|
|
58
|
-
*
|
|
59
|
-
* @member Config#dump
|
|
60
|
-
* @property {Set} ignore - keys to ignore
|
|
61
|
-
*/
|
|
62
|
-
dump: {
|
|
63
|
-
ignore: new Set([
|
|
64
|
-
'pass', 'pwd', 'passd', 'passwd', 'password', 'keys', 'masterKey', 'accessKey',
|
|
65
|
-
// ignore any key contains "secret" keyword
|
|
66
|
-
/secret/i,
|
|
67
|
-
]),
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* application home directory
|
|
72
|
-
* @member {String} Config#homeDir
|
|
73
|
-
* @default
|
|
74
|
-
* @since 1.0.0
|
|
75
|
-
*/
|
|
76
|
-
homeDir: appInfo.home,
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* application data & logs directory by env
|
|
80
|
-
* @member {String} Config#root
|
|
81
|
-
* @default
|
|
82
|
-
* @since 1.0.0
|
|
83
|
-
*/
|
|
84
|
-
root: appInfo.root,
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* application data directory
|
|
88
|
-
* @member {String} Config#appUserDataDir
|
|
89
|
-
* @default
|
|
90
|
-
* @since 1.0.0
|
|
91
|
-
*/
|
|
92
|
-
appUserDataDir: appInfo.appUserDataDir,
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* system user home dir
|
|
96
|
-
* @member {String} Config#userHome
|
|
97
|
-
*/
|
|
98
|
-
userHome: appInfo.userHome,
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* application version
|
|
102
|
-
* @member {String} Config#appVersion
|
|
103
|
-
*/
|
|
104
|
-
appVersion: appInfo.appVersion,
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* application package status
|
|
108
|
-
* @member {boolean} Config#isPackaged
|
|
109
|
-
*/
|
|
110
|
-
isPackaged: appInfo.isPackaged,
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* application exec file dir
|
|
114
|
-
* @member {String} Config#execDir
|
|
115
|
-
*/
|
|
116
|
-
execDir: appInfo.execDir
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* logger options
|
|
121
|
-
* @member Config#logger
|
|
122
|
-
* @property {String} dir - directory of log files
|
|
123
|
-
* @property {String} encoding - log file encoding, defaults to utf8
|
|
124
|
-
* @property {String} level - default log level, could be: DEBUG, INFO, WARN, ERROR or NONE, defaults to INFO in production
|
|
125
|
-
* @property {String} consoleLevel - log level of stdout, defaults to INFO in local serverEnv, defaults to WARN in unittest, defaults to NONE elsewise
|
|
126
|
-
* @property {Boolean} disableConsoleAfterReady - disable logger console after app ready. defaults to `false` on local and unittest env, others is `true`.
|
|
127
|
-
* @property {Boolean} outputJSON - log as JSON or not, defaults to false
|
|
128
|
-
* @property {Boolean} buffer - if enabled, flush logs to disk at a certain frequency to improve performance, defaults to true
|
|
129
|
-
* @property {String} errorLogName - file name of errorLogger
|
|
130
|
-
* @property {String} coreLogName - file name of coreLogger
|
|
131
|
-
* @property {String} agentLogName - file name of agent worker log
|
|
132
|
-
* @property {Object} coreLogger - custom config of coreLogger
|
|
133
|
-
* @property {Boolean} allowDebugAtProd - allow debug log at prod, defaults to false
|
|
134
|
-
* @property {Boolean} enablePerformanceTimer - using performance.now() timer instead of Date.now() for more more precise milliseconds, defaults to false. e.g.: logger will set 1.456ms instead of 1ms.
|
|
135
|
-
*/
|
|
136
|
-
config.logger = {
|
|
137
|
-
dir: path.join(appInfo.root, 'logs'),
|
|
138
|
-
encoding: 'utf8',
|
|
139
|
-
env: appInfo.env,
|
|
140
|
-
level: 'INFO',
|
|
141
|
-
consoleLevel: 'INFO',
|
|
142
|
-
disableConsoleAfterReady: appInfo.env !== 'local' && appInfo.env !== 'unittest',
|
|
143
|
-
outputJSON: false,
|
|
144
|
-
buffer: true,
|
|
145
|
-
appLogName: `ee.log`,
|
|
146
|
-
coreLogName: 'ee-core.log',
|
|
147
|
-
agentLogName: 'ee-agent.log',
|
|
148
|
-
errorLogName: `ee-error.log`,
|
|
149
|
-
coreLogger: {},
|
|
150
|
-
allowDebugAtProd: false,
|
|
151
|
-
enablePerformanceTimer: false,
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* The option for httpclient
|
|
156
|
-
* @member Config#httpclient
|
|
157
|
-
* @property {Boolean} enableDNSCache - Enable DNS lookup from local cache or not, default is false.
|
|
158
|
-
* @property {Boolean} dnsCacheLookupInterval - minimum interval of DNS query on the same hostname (default 10s).
|
|
159
|
-
*
|
|
160
|
-
* @property {Number} request.timeout - httpclient request default timeout, default is 5000 ms.
|
|
161
|
-
*
|
|
162
|
-
* @property {Boolean} httpAgent.keepAlive - Enable http agent keepalive or not, default is true
|
|
163
|
-
* @property {Number} httpAgent.freeSocketTimeout - http agent socket keepalive max free time, default is 4000 ms.
|
|
164
|
-
* @property {Number} httpAgent.maxSockets - http agent max socket number of one host, default is `Number.MAX_SAFE_INTEGER` @ses https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
|
|
165
|
-
* @property {Number} httpAgent.maxFreeSockets - http agent max free socket number of one host, default is 256.
|
|
166
|
-
*
|
|
167
|
-
* @property {Boolean} httpsAgent.keepAlive - Enable https agent keepalive or not, default is true
|
|
168
|
-
* @property {Number} httpsAgent.freeSocketTimeout - httpss agent socket keepalive max free time, default is 4000 ms.
|
|
169
|
-
* @property {Number} httpsAgent.maxSockets - https agent max socket number of one host, default is `Number.MAX_SAFE_INTEGER` @ses https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
|
|
170
|
-
* @property {Number} httpsAgent.maxFreeSockets - https agent max free socket number of one host, default is 256.
|
|
171
|
-
*/
|
|
172
|
-
config.httpclient = {
|
|
173
|
-
enableDNSCache: false,
|
|
174
|
-
dnsCacheLookupInterval: 10000,
|
|
175
|
-
dnsCacheMaxLength: 1000,
|
|
176
|
-
|
|
177
|
-
request: {
|
|
178
|
-
timeout: 5000,
|
|
179
|
-
},
|
|
180
|
-
httpAgent: {
|
|
181
|
-
keepAlive: true,
|
|
182
|
-
freeSocketTimeout: 4000,
|
|
183
|
-
maxSockets: Number.MAX_SAFE_INTEGER,
|
|
184
|
-
maxFreeSockets: 256,
|
|
185
|
-
},
|
|
186
|
-
httpsAgent: {
|
|
187
|
-
keepAlive: true,
|
|
188
|
-
freeSocketTimeout: 4000,
|
|
189
|
-
maxSockets: Number.MAX_SAFE_INTEGER,
|
|
190
|
-
maxFreeSockets: 256,
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
/* 内置socket服务 */
|
|
195
|
-
config.socketServer = {
|
|
196
|
-
enable: false, // 是否启用
|
|
197
|
-
port: 7070, // 默认端口(如果端口被使用,则随机获取一个)
|
|
198
|
-
path: "/socket.io/", // 路径名称
|
|
199
|
-
connectTimeout: 45000, // 客户端连接超时时间
|
|
200
|
-
pingTimeout: 30000, // 心跳检测超时时间
|
|
201
|
-
pingInterval: 25000, // 心跳检测间隔
|
|
202
|
-
maxHttpBufferSize: 1e8, // 每条消息的数据大小 1M
|
|
203
|
-
transports: ["polling", "websocket"], // http轮询和websocket
|
|
204
|
-
cors: {
|
|
205
|
-
origin: true, // http协议时,要设置跨域 类型 Boolean String RegExp Array Function
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
/* 内置http服务 */
|
|
210
|
-
config.httpServer = {
|
|
211
|
-
enable: false, // 是否启用
|
|
212
|
-
protocol: 'http://',
|
|
213
|
-
host: '127.0.0.1',
|
|
214
|
-
port: 7071, // 默认端口(如果端口被使用,则随机获取一个)
|
|
215
|
-
cors: {
|
|
216
|
-
origin: "*"
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
/* 主进程加载的地址 */
|
|
221
|
-
config.mainServer = {
|
|
222
|
-
protocol: 'http://',
|
|
223
|
-
host: '127.0.0.1',
|
|
224
|
-
port: 7072, // 默认端口(如果端口被使用,则随机获取一个)
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* 应用程序顶部菜单
|
|
229
|
-
* boolean | string
|
|
230
|
-
* true, false, 'dev-show'(dev环境显示,prod环境隐藏)
|
|
231
|
-
*/
|
|
232
|
-
config.openAppMenu = true;
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* 硬件加速
|
|
236
|
-
*/
|
|
237
|
-
config.hardGpu = {
|
|
238
|
-
enable: false
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* loading页(废弃)
|
|
243
|
-
*/
|
|
244
|
-
config.loadingPage = false;
|
|
245
|
-
|
|
246
|
-
return config;
|
|
247
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The configuration of ee application, can be access by `app.config`
|
|
6
|
+
* @class Config
|
|
7
|
+
* @since 1.0.0
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
module.exports = appInfo => {
|
|
11
|
+
|
|
12
|
+
const config = {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The environment of ee
|
|
16
|
+
* @member {String} Config#env
|
|
17
|
+
* @see {appInfo#env}
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
*/
|
|
20
|
+
env: appInfo.env,
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The name of the application
|
|
24
|
+
* @member {String} Config#name
|
|
25
|
+
* @see {appInfo#name}
|
|
26
|
+
* @since 1.0.0
|
|
27
|
+
*/
|
|
28
|
+
name: appInfo.name,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The current directory of the application
|
|
32
|
+
* @member {String} Config#baseDir
|
|
33
|
+
* @see {appInfo#baseDir}
|
|
34
|
+
* @since 1.0.0
|
|
35
|
+
*/
|
|
36
|
+
baseDir: appInfo.baseDir,
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The current HOME directory
|
|
40
|
+
* @member {String} Config#HOME
|
|
41
|
+
* @see {appInfo#HOME}
|
|
42
|
+
* @since 1.0.0
|
|
43
|
+
*/
|
|
44
|
+
HOME: appInfo.home,
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The directory of server running. You can find `application_config.json` under it that is dumpped from `app.config`.
|
|
48
|
+
* @member {String} Config#rundir
|
|
49
|
+
* @default
|
|
50
|
+
* @since 1.0.0
|
|
51
|
+
*/
|
|
52
|
+
rundir: path.join(appInfo.baseDir, 'run'),
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* dump config
|
|
56
|
+
*
|
|
57
|
+
* It will ignore special keys when dumpConfig
|
|
58
|
+
*
|
|
59
|
+
* @member Config#dump
|
|
60
|
+
* @property {Set} ignore - keys to ignore
|
|
61
|
+
*/
|
|
62
|
+
dump: {
|
|
63
|
+
ignore: new Set([
|
|
64
|
+
'pass', 'pwd', 'passd', 'passwd', 'password', 'keys', 'masterKey', 'accessKey',
|
|
65
|
+
// ignore any key contains "secret" keyword
|
|
66
|
+
/secret/i,
|
|
67
|
+
]),
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* application home directory
|
|
72
|
+
* @member {String} Config#homeDir
|
|
73
|
+
* @default
|
|
74
|
+
* @since 1.0.0
|
|
75
|
+
*/
|
|
76
|
+
homeDir: appInfo.home,
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* application data & logs directory by env
|
|
80
|
+
* @member {String} Config#root
|
|
81
|
+
* @default
|
|
82
|
+
* @since 1.0.0
|
|
83
|
+
*/
|
|
84
|
+
root: appInfo.root,
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* application data directory
|
|
88
|
+
* @member {String} Config#appUserDataDir
|
|
89
|
+
* @default
|
|
90
|
+
* @since 1.0.0
|
|
91
|
+
*/
|
|
92
|
+
appUserDataDir: appInfo.appUserDataDir,
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* system user home dir
|
|
96
|
+
* @member {String} Config#userHome
|
|
97
|
+
*/
|
|
98
|
+
userHome: appInfo.userHome,
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* application version
|
|
102
|
+
* @member {String} Config#appVersion
|
|
103
|
+
*/
|
|
104
|
+
appVersion: appInfo.appVersion,
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* application package status
|
|
108
|
+
* @member {boolean} Config#isPackaged
|
|
109
|
+
*/
|
|
110
|
+
isPackaged: appInfo.isPackaged,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* application exec file dir
|
|
114
|
+
* @member {String} Config#execDir
|
|
115
|
+
*/
|
|
116
|
+
execDir: appInfo.execDir
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* logger options
|
|
121
|
+
* @member Config#logger
|
|
122
|
+
* @property {String} dir - directory of log files
|
|
123
|
+
* @property {String} encoding - log file encoding, defaults to utf8
|
|
124
|
+
* @property {String} level - default log level, could be: DEBUG, INFO, WARN, ERROR or NONE, defaults to INFO in production
|
|
125
|
+
* @property {String} consoleLevel - log level of stdout, defaults to INFO in local serverEnv, defaults to WARN in unittest, defaults to NONE elsewise
|
|
126
|
+
* @property {Boolean} disableConsoleAfterReady - disable logger console after app ready. defaults to `false` on local and unittest env, others is `true`.
|
|
127
|
+
* @property {Boolean} outputJSON - log as JSON or not, defaults to false
|
|
128
|
+
* @property {Boolean} buffer - if enabled, flush logs to disk at a certain frequency to improve performance, defaults to true
|
|
129
|
+
* @property {String} errorLogName - file name of errorLogger
|
|
130
|
+
* @property {String} coreLogName - file name of coreLogger
|
|
131
|
+
* @property {String} agentLogName - file name of agent worker log
|
|
132
|
+
* @property {Object} coreLogger - custom config of coreLogger
|
|
133
|
+
* @property {Boolean} allowDebugAtProd - allow debug log at prod, defaults to false
|
|
134
|
+
* @property {Boolean} enablePerformanceTimer - using performance.now() timer instead of Date.now() for more more precise milliseconds, defaults to false. e.g.: logger will set 1.456ms instead of 1ms.
|
|
135
|
+
*/
|
|
136
|
+
config.logger = {
|
|
137
|
+
dir: path.join(appInfo.root, 'logs'),
|
|
138
|
+
encoding: 'utf8',
|
|
139
|
+
env: appInfo.env,
|
|
140
|
+
level: 'INFO',
|
|
141
|
+
consoleLevel: 'INFO',
|
|
142
|
+
disableConsoleAfterReady: appInfo.env !== 'local' && appInfo.env !== 'unittest',
|
|
143
|
+
outputJSON: false,
|
|
144
|
+
buffer: true,
|
|
145
|
+
appLogName: `ee.log`,
|
|
146
|
+
coreLogName: 'ee-core.log',
|
|
147
|
+
agentLogName: 'ee-agent.log',
|
|
148
|
+
errorLogName: `ee-error.log`,
|
|
149
|
+
coreLogger: {},
|
|
150
|
+
allowDebugAtProd: false,
|
|
151
|
+
enablePerformanceTimer: false,
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The option for httpclient
|
|
156
|
+
* @member Config#httpclient
|
|
157
|
+
* @property {Boolean} enableDNSCache - Enable DNS lookup from local cache or not, default is false.
|
|
158
|
+
* @property {Boolean} dnsCacheLookupInterval - minimum interval of DNS query on the same hostname (default 10s).
|
|
159
|
+
*
|
|
160
|
+
* @property {Number} request.timeout - httpclient request default timeout, default is 5000 ms.
|
|
161
|
+
*
|
|
162
|
+
* @property {Boolean} httpAgent.keepAlive - Enable http agent keepalive or not, default is true
|
|
163
|
+
* @property {Number} httpAgent.freeSocketTimeout - http agent socket keepalive max free time, default is 4000 ms.
|
|
164
|
+
* @property {Number} httpAgent.maxSockets - http agent max socket number of one host, default is `Number.MAX_SAFE_INTEGER` @ses https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
|
|
165
|
+
* @property {Number} httpAgent.maxFreeSockets - http agent max free socket number of one host, default is 256.
|
|
166
|
+
*
|
|
167
|
+
* @property {Boolean} httpsAgent.keepAlive - Enable https agent keepalive or not, default is true
|
|
168
|
+
* @property {Number} httpsAgent.freeSocketTimeout - httpss agent socket keepalive max free time, default is 4000 ms.
|
|
169
|
+
* @property {Number} httpsAgent.maxSockets - https agent max socket number of one host, default is `Number.MAX_SAFE_INTEGER` @ses https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
|
|
170
|
+
* @property {Number} httpsAgent.maxFreeSockets - https agent max free socket number of one host, default is 256.
|
|
171
|
+
*/
|
|
172
|
+
config.httpclient = {
|
|
173
|
+
enableDNSCache: false,
|
|
174
|
+
dnsCacheLookupInterval: 10000,
|
|
175
|
+
dnsCacheMaxLength: 1000,
|
|
176
|
+
|
|
177
|
+
request: {
|
|
178
|
+
timeout: 5000,
|
|
179
|
+
},
|
|
180
|
+
httpAgent: {
|
|
181
|
+
keepAlive: true,
|
|
182
|
+
freeSocketTimeout: 4000,
|
|
183
|
+
maxSockets: Number.MAX_SAFE_INTEGER,
|
|
184
|
+
maxFreeSockets: 256,
|
|
185
|
+
},
|
|
186
|
+
httpsAgent: {
|
|
187
|
+
keepAlive: true,
|
|
188
|
+
freeSocketTimeout: 4000,
|
|
189
|
+
maxSockets: Number.MAX_SAFE_INTEGER,
|
|
190
|
+
maxFreeSockets: 256,
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/* 内置socket服务 */
|
|
195
|
+
config.socketServer = {
|
|
196
|
+
enable: false, // 是否启用
|
|
197
|
+
port: 7070, // 默认端口(如果端口被使用,则随机获取一个)
|
|
198
|
+
path: "/socket.io/", // 路径名称
|
|
199
|
+
connectTimeout: 45000, // 客户端连接超时时间
|
|
200
|
+
pingTimeout: 30000, // 心跳检测超时时间
|
|
201
|
+
pingInterval: 25000, // 心跳检测间隔
|
|
202
|
+
maxHttpBufferSize: 1e8, // 每条消息的数据大小 1M
|
|
203
|
+
transports: ["polling", "websocket"], // http轮询和websocket
|
|
204
|
+
cors: {
|
|
205
|
+
origin: true, // http协议时,要设置跨域 类型 Boolean String RegExp Array Function
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
/* 内置http服务 */
|
|
210
|
+
config.httpServer = {
|
|
211
|
+
enable: false, // 是否启用
|
|
212
|
+
protocol: 'http://',
|
|
213
|
+
host: '127.0.0.1',
|
|
214
|
+
port: 7071, // 默认端口(如果端口被使用,则随机获取一个)
|
|
215
|
+
cors: {
|
|
216
|
+
origin: "*"
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/* 主进程加载的地址 */
|
|
221
|
+
config.mainServer = {
|
|
222
|
+
protocol: 'http://',
|
|
223
|
+
host: '127.0.0.1',
|
|
224
|
+
port: 7072, // 默认端口(如果端口被使用,则随机获取一个)
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* 应用程序顶部菜单
|
|
229
|
+
* boolean | string
|
|
230
|
+
* true, false, 'dev-show'(dev环境显示,prod环境隐藏)
|
|
231
|
+
*/
|
|
232
|
+
config.openAppMenu = true;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* 硬件加速
|
|
236
|
+
*/
|
|
237
|
+
config.hardGpu = {
|
|
238
|
+
enable: false
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* loading页(废弃)
|
|
243
|
+
*/
|
|
244
|
+
config.loadingPage = false;
|
|
245
|
+
|
|
246
|
+
return config;
|
|
247
|
+
};
|
package/core/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const EeCore = require('./lib/ee');
|
|
4
|
-
const EeLoader = require('./lib/loader/ee_loader');
|
|
5
|
-
const BaseContextClass = require('./lib/utils/base_context_class');
|
|
6
|
-
const utils = require('./lib/utils');
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
EeCore,
|
|
10
|
-
EeLoader,
|
|
11
|
-
BaseContextClass,
|
|
12
|
-
utils,
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const EeCore = require('./lib/ee');
|
|
4
|
+
const EeLoader = require('./lib/loader/ee_loader');
|
|
5
|
+
const BaseContextClass = require('./lib/utils/base_context_class');
|
|
6
|
+
const utils = require('./lib/utils');
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
EeCore,
|
|
10
|
+
EeLoader,
|
|
11
|
+
BaseContextClass,
|
|
12
|
+
utils,
|
|
13
13
|
};
|