egg 4.1.0-beta.35 → 4.1.0-beta.36
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/dist/agent.d.ts +7 -3
- package/dist/agent.js +10 -6
- package/dist/ajv.d.ts +1 -1
- package/dist/ajv.js +3 -2
- package/dist/aop.d.ts +1 -1
- package/dist/aop.js +3 -2
- package/dist/app/extend/context.d.ts +181 -178
- package/dist/app/extend/context.js +244 -259
- package/dist/app/extend/helper.d.ts +40 -35
- package/dist/app/extend/helper.js +45 -41
- package/dist/app/extend/request.d.ts +135 -131
- package/dist/app/extend/request.js +219 -258
- package/dist/app/extend/response.d.ts +28 -24
- package/dist/app/extend/response.js +36 -34
- package/dist/app/middleware/body_parser.d.ts +2 -2
- package/dist/app/middleware/body_parser.js +7 -3
- package/dist/app/middleware/meta.d.ts +8 -8
- package/dist/app/middleware/meta.js +15 -18
- package/dist/app/middleware/notfound.d.ts +8 -5
- package/dist/app/middleware/notfound.js +25 -28
- package/dist/app/middleware/override_method.d.ts +2 -2
- package/dist/app/middleware/override_method.js +7 -3
- package/dist/app/middleware/site_file.d.ts +11 -7
- package/dist/app/middleware/site_file.js +37 -52
- package/dist/config/config.default.d.ts +11 -6
- package/dist/config/config.default.js +258 -375
- package/dist/config/config.local.d.ts +6 -3
- package/dist/config/config.local.js +7 -8
- package/dist/config/config.unittest.d.ts +6 -3
- package/dist/config/config.unittest.js +10 -8
- package/dist/config/plugin.d.ts +6 -2
- package/dist/config/plugin.js +67 -131
- package/dist/dal.d.ts +1 -1
- package/dist/dal.js +3 -2
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +3 -2
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +3 -2
- package/dist/index.d.ts +24 -106
- package/dist/index.js +23 -89
- package/dist/lib/agent.d.ts +21 -15
- package/dist/lib/agent.js +53 -45
- package/dist/lib/application.d.ts +60 -54
- package/dist/lib/application.js +199 -249
- package/dist/lib/core/base_context_class.d.ts +23 -17
- package/dist/lib/core/base_context_class.js +17 -15
- package/dist/lib/core/base_context_logger.d.ts +39 -35
- package/dist/lib/core/base_context_logger.js +58 -60
- package/dist/lib/core/base_hook_class.d.ts +18 -11
- package/dist/lib/core/base_hook_class.js +26 -22
- package/dist/lib/core/context_httpclient.d.ts +21 -16
- package/dist/lib/core/context_httpclient.js +29 -26
- package/dist/lib/core/httpclient.d.ts +14 -12
- package/dist/lib/core/httpclient.js +34 -37
- package/dist/lib/core/logger.d.ts +7 -3
- package/dist/lib/core/logger.js +30 -36
- package/dist/lib/core/messenger/IMessenger.d.ts +53 -49
- package/dist/lib/core/messenger/IMessenger.js +1 -2
- package/dist/lib/core/messenger/base.d.ts +11 -7
- package/dist/lib/core/messenger/base.js +30 -29
- package/dist/lib/core/messenger/index.d.ts +10 -6
- package/dist/lib/core/messenger/index.js +11 -8
- package/dist/lib/core/messenger/ipc.d.ts +62 -57
- package/dist/lib/core/messenger/ipc.js +126 -138
- package/dist/lib/core/messenger/local.d.ts +63 -58
- package/dist/lib/core/messenger/local.js +126 -131
- package/dist/lib/core/utils.d.ts +5 -2
- package/dist/lib/core/utils.js +44 -66
- package/dist/lib/define.d.ts +72 -67
- package/dist/lib/define.js +54 -53
- package/dist/lib/egg.d.ts +283 -281
- package/dist/lib/egg.js +512 -573
- package/dist/lib/error/CookieLimitExceedError.d.ts +7 -4
- package/dist/lib/error/CookieLimitExceedError.js +15 -12
- package/dist/lib/error/MessageUnhandledRejectionError.d.ts +7 -4
- package/dist/lib/error/MessageUnhandledRejectionError.js +15 -12
- package/dist/lib/error/index.d.ts +3 -2
- package/dist/lib/error/index.js +4 -3
- package/dist/lib/loader/AgentWorkerLoader.d.ts +15 -10
- package/dist/lib/loader/AgentWorkerLoader.js +22 -18
- package/dist/lib/loader/AppWorkerLoader.d.ts +20 -15
- package/dist/lib/loader/AppWorkerLoader.js +35 -37
- package/dist/lib/loader/EggApplicationLoader.d.ts +7 -3
- package/dist/lib/loader/EggApplicationLoader.js +7 -4
- package/dist/lib/loader/index.d.ts +4 -3
- package/dist/lib/loader/index.js +5 -4
- package/dist/lib/start.d.ts +24 -20
- package/dist/lib/start.js +32 -42
- package/dist/lib/types.d.ts +288 -286
- package/dist/lib/types.js +2 -2
- package/dist/lib/types.plugin.d.ts +21 -21
- package/dist/lib/types.plugin.js +23 -24
- package/dist/orm.d.ts +1 -1
- package/dist/orm.js +3 -2
- package/dist/schedule.d.ts +2 -2
- package/dist/schedule.js +5 -5
- package/dist/transaction.d.ts +1 -1
- package/dist/transaction.js +3 -2
- package/dist/urllib.d.ts +1 -1
- package/dist/urllib.js +3 -2
- package/package.json +60 -64
|
@@ -1,378 +1,261 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { defineConfigFactory } from "../lib/define.js";
|
|
2
|
+
import "../index.js";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
|
|
6
|
+
//#region src/config/config.default.ts
|
|
4
7
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
* The configuration of egg application, can be access by `app.config`
|
|
9
|
+
* @class Config
|
|
10
|
+
* @since 1.0.0
|
|
11
|
+
*/
|
|
9
12
|
const factory = defineConfigFactory((appInfo) => {
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
* @property {Boolean} allowDebugAtProd - allow debug log at prod, defaults to false
|
|
255
|
-
* @property {Boolean} enableFastContextLogger - using the app logger instead of EggContextLogger, defaults to true
|
|
256
|
-
*/
|
|
257
|
-
config.logger = {
|
|
258
|
-
dir: path.join(appInfo.root, 'logs', appInfo.name),
|
|
259
|
-
encoding: 'utf8',
|
|
260
|
-
env: appInfo.env,
|
|
261
|
-
level: 'INFO',
|
|
262
|
-
consoleLevel: 'INFO',
|
|
263
|
-
disableConsoleAfterReady: appInfo.env !== 'local' && appInfo.env !== 'unittest',
|
|
264
|
-
outputJSON: false,
|
|
265
|
-
buffer: true,
|
|
266
|
-
appLogName: `${appInfo.name}-web.log`,
|
|
267
|
-
coreLogName: 'egg-web.log',
|
|
268
|
-
agentLogName: 'egg-agent.log',
|
|
269
|
-
errorLogName: 'common-error.log',
|
|
270
|
-
coreLogger: {},
|
|
271
|
-
allowDebugAtProd: false,
|
|
272
|
-
enableFastContextLogger: true,
|
|
273
|
-
};
|
|
274
|
-
/**
|
|
275
|
-
* The option for httpclient
|
|
276
|
-
* @member Config#httpclient
|
|
277
|
-
* @property {Boolean} enableDNSCache - Enable DNS lookup from local cache or not, default is false.
|
|
278
|
-
* @property {Boolean} dnsCacheLookupInterval - minimum interval of DNS query on the same hostname (default 10s).
|
|
279
|
-
*
|
|
280
|
-
* @property {Number} request.timeout - httpclient request default timeout, default is 5000 ms.
|
|
281
|
-
*
|
|
282
|
-
* @property {Boolean} httpAgent.keepAlive - Enable http agent keepalive or not, default is true
|
|
283
|
-
* @property {Number} httpAgent.freeSocketTimeout - http agent socket keepalive max free time, default is 4000 ms.
|
|
284
|
-
* @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
|
|
285
|
-
* @property {Number} httpAgent.maxFreeSockets - http agent max free socket number of one host, default is 256.
|
|
286
|
-
*
|
|
287
|
-
* @property {Boolean} httpsAgent.keepAlive - Enable https agent keepalive or not, default is true
|
|
288
|
-
* @property {Number} httpsAgent.freeSocketTimeout - https agent socket keepalive max free time, default is 4000 ms.
|
|
289
|
-
* @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
|
|
290
|
-
* @property {Number} httpsAgent.maxFreeSockets - https agent max free socket number of one host, default is 256.
|
|
291
|
-
* @property {Boolean} useHttpClientNext - use urllib@3 HttpClient
|
|
292
|
-
*/
|
|
293
|
-
config.httpclient = {
|
|
294
|
-
request: {
|
|
295
|
-
timeout: 5000,
|
|
296
|
-
},
|
|
297
|
-
};
|
|
298
|
-
/**
|
|
299
|
-
* The options of `meta` middleware
|
|
300
|
-
*
|
|
301
|
-
* @member Config#meta
|
|
302
|
-
* @property {Boolean} enable - enable meta or not, default is `true`
|
|
303
|
-
* @property {Boolean} logging - enable logging start request, default is `false`
|
|
304
|
-
*/
|
|
305
|
-
config.meta = {
|
|
306
|
-
enable: true,
|
|
307
|
-
logging: false,
|
|
308
|
-
};
|
|
309
|
-
/**
|
|
310
|
-
* core enable middlewares
|
|
311
|
-
* @member {Array} Config#middleware
|
|
312
|
-
*/
|
|
313
|
-
config.coreMiddleware = ['meta', 'siteFile', 'notfound', 'bodyParser', 'overrideMethod'];
|
|
314
|
-
/**
|
|
315
|
-
* emit `startTimeout` if worker don't ready after `workerStartTimeout` ms
|
|
316
|
-
* @member {Number} Config.workerStartTimeout
|
|
317
|
-
*/
|
|
318
|
-
config.workerStartTimeout = 10 * 60 * 1000;
|
|
319
|
-
/**
|
|
320
|
-
* server timeout in milliseconds, default to 0 (no timeout).
|
|
321
|
-
*
|
|
322
|
-
* for special request, just use `ctx.req.setTimeout(ms)`
|
|
323
|
-
*
|
|
324
|
-
* @member {Number} Config#serverTimeout
|
|
325
|
-
* @see https://nodejs.org/api/http.html#http_server_timeout
|
|
326
|
-
*/
|
|
327
|
-
config.serverTimeout = null;
|
|
328
|
-
/**
|
|
329
|
-
* The options of cluster
|
|
330
|
-
* @member {Object} Config#cluster
|
|
331
|
-
* @property {Object} listen - listen options, see {@link https://nodejs.org/api/http.html#http_server_listen_port_hostname_backlog_callback}
|
|
332
|
-
* @property {String} listen.path - set a unix sock path when server listen
|
|
333
|
-
* @property {Number} listen.port - set a port when server listen
|
|
334
|
-
* @property {String} listen.hostname - set a hostname binding server when server listen
|
|
335
|
-
*/
|
|
336
|
-
config.cluster = {
|
|
337
|
-
listen: {
|
|
338
|
-
path: '',
|
|
339
|
-
port: 7001,
|
|
340
|
-
hostname: '',
|
|
341
|
-
},
|
|
342
|
-
};
|
|
343
|
-
/**
|
|
344
|
-
* @property {Number} responseTimeout - response timeout, default is 60000
|
|
345
|
-
*/
|
|
346
|
-
config.clusterClient = {
|
|
347
|
-
maxWaitTime: 60000,
|
|
348
|
-
responseTimeout: 60000,
|
|
349
|
-
};
|
|
350
|
-
/**
|
|
351
|
-
* This function / async function will be called when a client error occurred and return the response.
|
|
352
|
-
*
|
|
353
|
-
* The arguments are `err`, `socket` and `application` which indicate current client error object, current socket
|
|
354
|
-
* object and the application object.
|
|
355
|
-
*
|
|
356
|
-
* The response to be returned should include properties below:
|
|
357
|
-
*
|
|
358
|
-
* @member {Function} Config#onClientError
|
|
359
|
-
* @property [body] {String|Buffer} - the response body
|
|
360
|
-
* @property [status] {Number} - the response status code
|
|
361
|
-
* @property [headers] {Object} - the response header key-value pairs
|
|
362
|
-
*
|
|
363
|
-
* @example
|
|
364
|
-
* exports.onClientError = async (err, socket, app) => {
|
|
365
|
-
* return {
|
|
366
|
-
* body: 'error',
|
|
367
|
-
* status: 400,
|
|
368
|
-
* headers: {
|
|
369
|
-
* 'powered-by': 'Egg.js',
|
|
370
|
-
* }
|
|
371
|
-
* };
|
|
372
|
-
* }
|
|
373
|
-
*/
|
|
374
|
-
config.onClientError = undefined;
|
|
375
|
-
return config;
|
|
13
|
+
const config = {
|
|
14
|
+
env: appInfo.env,
|
|
15
|
+
name: appInfo.name,
|
|
16
|
+
keys: "",
|
|
17
|
+
cookies: {},
|
|
18
|
+
proxy: false,
|
|
19
|
+
maxIpsCount: 0,
|
|
20
|
+
maxProxyCount: 0,
|
|
21
|
+
protocolHeaders: "x-forwarded-proto",
|
|
22
|
+
ipHeaders: "x-forwarded-for",
|
|
23
|
+
hostHeaders: "",
|
|
24
|
+
pkg: appInfo.pkg,
|
|
25
|
+
baseDir: appInfo.baseDir,
|
|
26
|
+
HOME: appInfo.HOME,
|
|
27
|
+
rundir: path.join(appInfo.baseDir, "run"),
|
|
28
|
+
dump: {
|
|
29
|
+
ignore: new Set([
|
|
30
|
+
"pass",
|
|
31
|
+
"pwd",
|
|
32
|
+
"passd",
|
|
33
|
+
"passwd",
|
|
34
|
+
"password",
|
|
35
|
+
"keys",
|
|
36
|
+
"masterKey",
|
|
37
|
+
"accessKey",
|
|
38
|
+
/secret/i
|
|
39
|
+
]),
|
|
40
|
+
timing: { slowBootActionMinDuration: 5e3 }
|
|
41
|
+
},
|
|
42
|
+
confusedConfigurations: {
|
|
43
|
+
bodyparser: "bodyParser",
|
|
44
|
+
notFound: "notfound",
|
|
45
|
+
sitefile: "siteFile",
|
|
46
|
+
middlewares: "middleware",
|
|
47
|
+
httpClient: "httpclient"
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The options of `notfound` middleware
|
|
52
|
+
*
|
|
53
|
+
* It will return page or json depend on negotiation when 404,
|
|
54
|
+
* If pageUrl is set, it will redirect to the page.
|
|
55
|
+
*
|
|
56
|
+
* @member Config#notfound
|
|
57
|
+
* @property {String} pageUrl - the 404 page url
|
|
58
|
+
*/
|
|
59
|
+
config.notfound = {
|
|
60
|
+
enable: true,
|
|
61
|
+
pageUrl: ""
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* The option of `siteFile` middleware
|
|
65
|
+
*
|
|
66
|
+
* You can map some files using this options, it will response immediately when matching.
|
|
67
|
+
*
|
|
68
|
+
* @member {Object} Config#siteFile - key is path, and value is url or buffer.
|
|
69
|
+
* @property {String} cacheControl - files cache control, default is `public, max-age=2592000`
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* // specific app's favicon, => '/favicon.ico': 'https://eggjs.org/favicon.png',
|
|
73
|
+
* config.siteFile = {
|
|
74
|
+
* '/favicon.ico': 'https://eggjs.org/favicon.png',
|
|
75
|
+
* };
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
config.siteFile = {
|
|
79
|
+
enable: true,
|
|
80
|
+
"/favicon.ico": pathToFileURL(path.join(import.meta.dirname, "favicon.png")),
|
|
81
|
+
cacheControl: "public, max-age=2592000"
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* The options of `bodyParser` middleware
|
|
85
|
+
*
|
|
86
|
+
* @member Config#bodyParser
|
|
87
|
+
* @property {Boolean} enable - enable bodyParser or not, default is true
|
|
88
|
+
* @property {String | RegExp | Function | Array} ignore - won't parse request body when url path hit ignore pattern, can not set `ignore` when `match` presented
|
|
89
|
+
* @property {String | RegExp | Function | Array} match - will parse request body only when url path hit match pattern
|
|
90
|
+
* @property {String} encoding - body's encoding type,default is utf8
|
|
91
|
+
* @property {String} formLimit - limit of the urlencoded body. If the body ends up being larger than this limit, a 413 error code is returned. Default is 1mb
|
|
92
|
+
* @property {String} jsonLimit - limit of the json body, default is 1mb
|
|
93
|
+
* @property {String} textLimit - limit of the text body, default is 1mb
|
|
94
|
+
* @property {Boolean} strict - when set to true, JSON parser will only accept arrays and objects. Default is true
|
|
95
|
+
* @property {Number} queryString.arrayLimit - urlencoded body array's max length, default is 100
|
|
96
|
+
* @property {Number} queryString.depth - urlencoded body object's max depth, default is 5
|
|
97
|
+
* @property {Number} queryString.parameterLimit - urlencoded body maximum parameters, default is 1000
|
|
98
|
+
*/
|
|
99
|
+
config.bodyParser = {
|
|
100
|
+
enable: true,
|
|
101
|
+
encoding: "utf8",
|
|
102
|
+
formLimit: "1mb",
|
|
103
|
+
jsonLimit: "1mb",
|
|
104
|
+
textLimit: "1mb",
|
|
105
|
+
strict: true,
|
|
106
|
+
queryString: {
|
|
107
|
+
arrayLimit: 100,
|
|
108
|
+
depth: 5,
|
|
109
|
+
parameterLimit: 1e3
|
|
110
|
+
},
|
|
111
|
+
onProtoPoisoning: "error",
|
|
112
|
+
onerror(err, ctx) {
|
|
113
|
+
err.message = `${err.message}, check bodyParser config`;
|
|
114
|
+
if (ctx.status === 404) {
|
|
115
|
+
ctx.status = 400;
|
|
116
|
+
if (!err.status) err.status = 400;
|
|
117
|
+
}
|
|
118
|
+
throw err;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* logger options
|
|
123
|
+
* @member Config#logger
|
|
124
|
+
* @property {String} dir - directory of log files
|
|
125
|
+
* @property {String} encoding - log file encoding, defaults to utf8
|
|
126
|
+
* @property {String} level - default log level, could be: DEBUG, INFO, WARN, ERROR or NONE, defaults to INFO in production
|
|
127
|
+
* @property {String} consoleLevel - log level of stdout, defaults to INFO in local serverEnv, defaults to WARN in unittest, defaults to NONE elsewise
|
|
128
|
+
* @property {Boolean} disableConsoleAfterReady - disable logger console after app ready. defaults to `false` on local and unittest env, others is `true`.
|
|
129
|
+
* @property {Boolean} outputJSON - log as JSON or not, defaults to false
|
|
130
|
+
* @property {Boolean} buffer - if enabled, flush logs to disk at a certain frequency to improve performance, defaults to true
|
|
131
|
+
* @property {String} errorLogName - file name of errorLogger
|
|
132
|
+
* @property {String} coreLogName - file name of coreLogger
|
|
133
|
+
* @property {String} agentLogName - file name of agent worker log
|
|
134
|
+
* @property {Object} coreLogger - custom config of coreLogger
|
|
135
|
+
* @property {Boolean} allowDebugAtProd - allow debug log at prod, defaults to false
|
|
136
|
+
* @property {Boolean} enableFastContextLogger - using the app logger instead of EggContextLogger, defaults to true
|
|
137
|
+
*/
|
|
138
|
+
config.logger = {
|
|
139
|
+
dir: path.join(appInfo.root, "logs", appInfo.name),
|
|
140
|
+
encoding: "utf8",
|
|
141
|
+
env: appInfo.env,
|
|
142
|
+
level: "INFO",
|
|
143
|
+
consoleLevel: "INFO",
|
|
144
|
+
disableConsoleAfterReady: appInfo.env !== "local" && appInfo.env !== "unittest",
|
|
145
|
+
outputJSON: false,
|
|
146
|
+
buffer: true,
|
|
147
|
+
appLogName: `${appInfo.name}-web.log`,
|
|
148
|
+
coreLogName: "egg-web.log",
|
|
149
|
+
agentLogName: "egg-agent.log",
|
|
150
|
+
errorLogName: "common-error.log",
|
|
151
|
+
coreLogger: {},
|
|
152
|
+
allowDebugAtProd: false,
|
|
153
|
+
enableFastContextLogger: true
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* The option for httpclient
|
|
157
|
+
* @member Config#httpclient
|
|
158
|
+
* @property {Boolean} enableDNSCache - Enable DNS lookup from local cache or not, default is false.
|
|
159
|
+
* @property {Boolean} dnsCacheLookupInterval - minimum interval of DNS query on the same hostname (default 10s).
|
|
160
|
+
*
|
|
161
|
+
* @property {Number} request.timeout - httpclient request default timeout, default is 5000 ms.
|
|
162
|
+
*
|
|
163
|
+
* @property {Boolean} httpAgent.keepAlive - Enable http agent keepalive or not, default is true
|
|
164
|
+
* @property {Number} httpAgent.freeSocketTimeout - http agent socket keepalive max free time, default is 4000 ms.
|
|
165
|
+
* @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
|
|
166
|
+
* @property {Number} httpAgent.maxFreeSockets - http agent max free socket number of one host, default is 256.
|
|
167
|
+
*
|
|
168
|
+
* @property {Boolean} httpsAgent.keepAlive - Enable https agent keepalive or not, default is true
|
|
169
|
+
* @property {Number} httpsAgent.freeSocketTimeout - https agent socket keepalive max free time, default is 4000 ms.
|
|
170
|
+
* @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
|
|
171
|
+
* @property {Number} httpsAgent.maxFreeSockets - https agent max free socket number of one host, default is 256.
|
|
172
|
+
* @property {Boolean} useHttpClientNext - use urllib@3 HttpClient
|
|
173
|
+
*/
|
|
174
|
+
config.httpclient = { request: { timeout: 5e3 } };
|
|
175
|
+
/**
|
|
176
|
+
* The options of `meta` middleware
|
|
177
|
+
*
|
|
178
|
+
* @member Config#meta
|
|
179
|
+
* @property {Boolean} enable - enable meta or not, default is `true`
|
|
180
|
+
* @property {Boolean} logging - enable logging start request, default is `false`
|
|
181
|
+
*/
|
|
182
|
+
config.meta = {
|
|
183
|
+
enable: true,
|
|
184
|
+
logging: false
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* core enable middlewares
|
|
188
|
+
* @member {Array} Config#middleware
|
|
189
|
+
*/
|
|
190
|
+
config.coreMiddleware = [
|
|
191
|
+
"meta",
|
|
192
|
+
"siteFile",
|
|
193
|
+
"notfound",
|
|
194
|
+
"bodyParser",
|
|
195
|
+
"overrideMethod"
|
|
196
|
+
];
|
|
197
|
+
/**
|
|
198
|
+
* emit `startTimeout` if worker don't ready after `workerStartTimeout` ms
|
|
199
|
+
* @member {Number} Config.workerStartTimeout
|
|
200
|
+
*/
|
|
201
|
+
config.workerStartTimeout = 600 * 1e3;
|
|
202
|
+
/**
|
|
203
|
+
* server timeout in milliseconds, default to 0 (no timeout).
|
|
204
|
+
*
|
|
205
|
+
* for special request, just use `ctx.req.setTimeout(ms)`
|
|
206
|
+
*
|
|
207
|
+
* @member {Number} Config#serverTimeout
|
|
208
|
+
* @see https://nodejs.org/api/http.html#http_server_timeout
|
|
209
|
+
*/
|
|
210
|
+
config.serverTimeout = null;
|
|
211
|
+
/**
|
|
212
|
+
* The options of cluster
|
|
213
|
+
* @member {Object} Config#cluster
|
|
214
|
+
* @property {Object} listen - listen options, see {@link https://nodejs.org/api/http.html#http_server_listen_port_hostname_backlog_callback}
|
|
215
|
+
* @property {String} listen.path - set a unix sock path when server listen
|
|
216
|
+
* @property {Number} listen.port - set a port when server listen
|
|
217
|
+
* @property {String} listen.hostname - set a hostname binding server when server listen
|
|
218
|
+
*/
|
|
219
|
+
config.cluster = { listen: {
|
|
220
|
+
path: "",
|
|
221
|
+
port: 7001,
|
|
222
|
+
hostname: ""
|
|
223
|
+
} };
|
|
224
|
+
/**
|
|
225
|
+
* @property {Number} responseTimeout - response timeout, default is 60000
|
|
226
|
+
*/
|
|
227
|
+
config.clusterClient = {
|
|
228
|
+
maxWaitTime: 6e4,
|
|
229
|
+
responseTimeout: 6e4
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* This function / async function will be called when a client error occurred and return the response.
|
|
233
|
+
*
|
|
234
|
+
* The arguments are `err`, `socket` and `application` which indicate current client error object, current socket
|
|
235
|
+
* object and the application object.
|
|
236
|
+
*
|
|
237
|
+
* The response to be returned should include properties below:
|
|
238
|
+
*
|
|
239
|
+
* @member {Function} Config#onClientError
|
|
240
|
+
* @property [body] {String|Buffer} - the response body
|
|
241
|
+
* @property [status] {Number} - the response status code
|
|
242
|
+
* @property [headers] {Object} - the response header key-value pairs
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* exports.onClientError = async (err, socket, app) => {
|
|
246
|
+
* return {
|
|
247
|
+
* body: 'error',
|
|
248
|
+
* status: 400,
|
|
249
|
+
* headers: {
|
|
250
|
+
* 'powered-by': 'Egg.js',
|
|
251
|
+
* }
|
|
252
|
+
* };
|
|
253
|
+
* }
|
|
254
|
+
*/
|
|
255
|
+
config.onClientError = void 0;
|
|
256
|
+
return config;
|
|
376
257
|
});
|
|
377
|
-
|
|
378
|
-
|
|
258
|
+
var config_default_default = factory;
|
|
259
|
+
|
|
260
|
+
//#endregion
|
|
261
|
+
export { config_default_default as default };
|