egg 4.1.0-beta.34 → 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.
Files changed (101) hide show
  1. package/dist/agent.d.ts +7 -3
  2. package/dist/agent.js +10 -6
  3. package/dist/ajv.d.ts +1 -1
  4. package/dist/ajv.js +3 -2
  5. package/dist/aop.d.ts +1 -1
  6. package/dist/aop.js +3 -2
  7. package/dist/app/extend/context.d.ts +181 -178
  8. package/dist/app/extend/context.js +244 -259
  9. package/dist/app/extend/helper.d.ts +40 -35
  10. package/dist/app/extend/helper.js +45 -41
  11. package/dist/app/extend/request.d.ts +135 -131
  12. package/dist/app/extend/request.js +219 -258
  13. package/dist/app/extend/response.d.ts +28 -24
  14. package/dist/app/extend/response.js +36 -34
  15. package/dist/app/middleware/body_parser.d.ts +2 -2
  16. package/dist/app/middleware/body_parser.js +7 -3
  17. package/dist/app/middleware/meta.d.ts +8 -8
  18. package/dist/app/middleware/meta.js +15 -18
  19. package/dist/app/middleware/notfound.d.ts +8 -5
  20. package/dist/app/middleware/notfound.js +25 -28
  21. package/dist/app/middleware/override_method.d.ts +2 -2
  22. package/dist/app/middleware/override_method.js +7 -3
  23. package/dist/app/middleware/site_file.d.ts +11 -7
  24. package/dist/app/middleware/site_file.js +37 -52
  25. package/dist/config/config.default.d.ts +11 -6
  26. package/dist/config/config.default.js +258 -375
  27. package/dist/config/config.local.d.ts +6 -3
  28. package/dist/config/config.local.js +7 -8
  29. package/dist/config/config.unittest.d.ts +6 -3
  30. package/dist/config/config.unittest.js +10 -8
  31. package/dist/config/plugin.d.ts +6 -2
  32. package/dist/config/plugin.js +67 -131
  33. package/dist/dal.d.ts +1 -1
  34. package/dist/dal.js +3 -2
  35. package/dist/errors.d.ts +1 -1
  36. package/dist/errors.js +3 -2
  37. package/dist/helper.d.ts +1 -1
  38. package/dist/helper.js +3 -2
  39. package/dist/index.d.ts +24 -106
  40. package/dist/index.js +23 -89
  41. package/dist/lib/agent.d.ts +21 -15
  42. package/dist/lib/agent.js +53 -45
  43. package/dist/lib/application.d.ts +60 -54
  44. package/dist/lib/application.js +200 -250
  45. package/dist/lib/core/base_context_class.d.ts +23 -17
  46. package/dist/lib/core/base_context_class.js +17 -15
  47. package/dist/lib/core/base_context_logger.d.ts +39 -35
  48. package/dist/lib/core/base_context_logger.js +58 -60
  49. package/dist/lib/core/base_hook_class.d.ts +18 -11
  50. package/dist/lib/core/base_hook_class.js +26 -22
  51. package/dist/lib/core/context_httpclient.d.ts +21 -16
  52. package/dist/lib/core/context_httpclient.js +29 -26
  53. package/dist/lib/core/httpclient.d.ts +14 -12
  54. package/dist/lib/core/httpclient.js +34 -37
  55. package/dist/lib/core/logger.d.ts +7 -3
  56. package/dist/lib/core/logger.js +30 -36
  57. package/dist/lib/core/messenger/IMessenger.d.ts +53 -49
  58. package/dist/lib/core/messenger/IMessenger.js +1 -2
  59. package/dist/lib/core/messenger/base.d.ts +11 -7
  60. package/dist/lib/core/messenger/base.js +30 -29
  61. package/dist/lib/core/messenger/index.d.ts +10 -6
  62. package/dist/lib/core/messenger/index.js +11 -8
  63. package/dist/lib/core/messenger/ipc.d.ts +62 -57
  64. package/dist/lib/core/messenger/ipc.js +126 -138
  65. package/dist/lib/core/messenger/local.d.ts +63 -58
  66. package/dist/lib/core/messenger/local.js +126 -131
  67. package/dist/lib/core/utils.d.ts +5 -2
  68. package/dist/lib/core/utils.js +44 -66
  69. package/dist/lib/define.d.ts +72 -67
  70. package/dist/lib/define.js +54 -53
  71. package/dist/lib/egg.d.ts +283 -281
  72. package/dist/lib/egg.js +512 -573
  73. package/dist/lib/error/CookieLimitExceedError.d.ts +7 -4
  74. package/dist/lib/error/CookieLimitExceedError.js +15 -12
  75. package/dist/lib/error/MessageUnhandledRejectionError.d.ts +7 -4
  76. package/dist/lib/error/MessageUnhandledRejectionError.js +15 -12
  77. package/dist/lib/error/index.d.ts +3 -2
  78. package/dist/lib/error/index.js +4 -3
  79. package/dist/lib/loader/AgentWorkerLoader.d.ts +15 -10
  80. package/dist/lib/loader/AgentWorkerLoader.js +22 -18
  81. package/dist/lib/loader/AppWorkerLoader.d.ts +20 -15
  82. package/dist/lib/loader/AppWorkerLoader.js +35 -37
  83. package/dist/lib/loader/EggApplicationLoader.d.ts +7 -3
  84. package/dist/lib/loader/EggApplicationLoader.js +7 -4
  85. package/dist/lib/loader/index.d.ts +4 -3
  86. package/dist/lib/loader/index.js +5 -4
  87. package/dist/lib/start.d.ts +24 -20
  88. package/dist/lib/start.js +32 -42
  89. package/dist/lib/types.d.ts +288 -286
  90. package/dist/lib/types.js +2 -2
  91. package/dist/lib/types.plugin.d.ts +21 -21
  92. package/dist/lib/types.plugin.js +23 -24
  93. package/dist/orm.d.ts +1 -1
  94. package/dist/orm.js +3 -2
  95. package/dist/schedule.d.ts +2 -2
  96. package/dist/schedule.js +5 -5
  97. package/dist/transaction.d.ts +1 -1
  98. package/dist/transaction.js +3 -2
  99. package/dist/urllib.d.ts +1 -1
  100. package/dist/urllib.js +3 -2
  101. package/package.json +60 -64
@@ -1,378 +1,261 @@
1
- import path from 'node:path';
2
- import { pathToFileURL } from 'node:url';
3
- import { defineConfigFactory } from "../index.js";
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
- * The configuration of egg application, can be access by `app.config`
6
- * @class Config
7
- * @since 1.0.0
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
- const config = {
11
- /**
12
- * The environment of egg
13
- * @member {String} Config#env
14
- * @see {appInfo#env}
15
- * @since 1.0.0
16
- */
17
- env: appInfo.env,
18
- /**
19
- * The name of the application
20
- * @member {String} Config#name
21
- * @see {appInfo#name}
22
- * @since 1.0.0
23
- */
24
- name: appInfo.name,
25
- /**
26
- * The key that signing cookies. It can contain multiple keys separated by `,`.
27
- * @member {String} Config#keys
28
- * @see https://eggjs.org/core/cookie-and-session#cookie-secret-key
29
- * @default
30
- * @since 1.0.0
31
- */
32
- keys: '',
33
- /**
34
- * default cookie options
35
- *
36
- * @member Config#cookies
37
- * @property {String} sameSite - SameSite property, defaults is ''
38
- * @property {Boolean} httpOnly - httpOnly property, defaults is true
39
- */
40
- cookies: {
41
- // httpOnly: true | false,
42
- // sameSite: 'none|lax|strict',
43
- },
44
- /**
45
- * Whether application deployed after a reverse proxy,
46
- * when true proxy header fields will be trusted
47
- * @member {Boolean} Config#proxy
48
- * @default
49
- * @since 1.0.0
50
- */
51
- proxy: false,
52
- /**
53
- *
54
- * max ips read from proxy ip header, default to 0 (means infinity)
55
- * to prevent users from forging client ip addresses via x-forwarded-for
56
- * @see https://github.com/koajs/koa/blob/master/docs/api/request.md#requestips
57
- * @member {Integer} Config#maxIpsCount
58
- * @default
59
- * @since 2.25.0
60
- */
61
- maxIpsCount: 0,
62
- /**
63
- * please use maxIpsCount instead
64
- * @member {Integer} Config#maxProxyCount
65
- * @default
66
- * @since 2.21.0
67
- * @deprecated
68
- */
69
- maxProxyCount: 0,
70
- /**
71
- * Detect request's protocol from specified headers, not case-sensitive.
72
- * Only worked when config.proxy set to true.
73
- * @member {String} Config#protocolHeaders
74
- * @default
75
- * @since 1.0.0
76
- */
77
- protocolHeaders: 'x-forwarded-proto',
78
- /**
79
- * Detect request' ip from specified headers, not case-sensitive.
80
- * Only worked when config.proxy set to true.
81
- * @member {String} Config#ipHeaders
82
- * @default
83
- * @since 1.0.0
84
- */
85
- ipHeaders: 'x-forwarded-for',
86
- /**
87
- * Detect request' host from specified headers, not case-sensitive.
88
- * Only worked when config.proxy set to true.
89
- * @member {String} Config#hostHeaders
90
- * @default
91
- * @since 1.0.0
92
- */
93
- hostHeaders: '',
94
- /**
95
- * package.json
96
- * @member {Object} Config#pkg
97
- * @see {appInfo#pkg}
98
- * @since 1.0.0
99
- */
100
- pkg: appInfo.pkg,
101
- /**
102
- * The current directory of the application
103
- * @member {String} Config#baseDir
104
- * @see {appInfo#baseDir}
105
- * @since 1.0.0
106
- */
107
- baseDir: appInfo.baseDir,
108
- /**
109
- * The current HOME directory
110
- * @member {String} Config#HOME
111
- * @see {appInfo#HOME}
112
- * @since 1.0.0
113
- */
114
- HOME: appInfo.HOME,
115
- /**
116
- * The directory of server running. You can find `application_config.json` under it that is dumped from `app.config`.
117
- * @member {String} Config#rundir
118
- * @default
119
- * @since 1.0.0
120
- */
121
- rundir: path.join(appInfo.baseDir, 'run'),
122
- /**
123
- * dump config
124
- *
125
- * It will ignore special keys when dumpConfig
126
- *
127
- * @member Config#dump
128
- * @property {Set} ignore - keys to ignore
129
- */
130
- dump: {
131
- ignore: new Set([
132
- 'pass',
133
- 'pwd',
134
- 'passd',
135
- 'passwd',
136
- 'password',
137
- 'keys',
138
- 'masterKey',
139
- 'accessKey',
140
- // ignore any key contains "secret" keyword
141
- /secret/i,
142
- ]),
143
- timing: {
144
- // if boot action >= slowBootActionMinDuration, egg core will print it to warning log
145
- slowBootActionMinDuration: 5000,
146
- },
147
- },
148
- /**
149
- * configurations are confused to users
150
- * {
151
- * [unexpectedKey]: [expectedKey],
152
- * }
153
- * @member Config#confusedConfigurations
154
- * @type {Object}
155
- */
156
- confusedConfigurations: {
157
- bodyparser: 'bodyParser',
158
- notFound: 'notfound',
159
- sitefile: 'siteFile',
160
- middlewares: 'middleware',
161
- httpClient: 'httpclient',
162
- },
163
- };
164
- /**
165
- * The options of `notfound` middleware
166
- *
167
- * It will return page or json depend on negotiation when 404,
168
- * If pageUrl is set, it will redirect to the page.
169
- *
170
- * @member Config#notfound
171
- * @property {String} pageUrl - the 404 page url
172
- */
173
- config.notfound = {
174
- enable: true,
175
- pageUrl: '',
176
- };
177
- /**
178
- * The option of `siteFile` middleware
179
- *
180
- * You can map some files using this options, it will response immediately when matching.
181
- *
182
- * @member {Object} Config#siteFile - key is path, and value is url or buffer.
183
- * @property {String} cacheControl - files cache control, default is `public, max-age=2592000`
184
- * @example
185
- * ```ts
186
- * // specific app's favicon, => '/favicon.ico': 'https://eggjs.org/favicon.png',
187
- * config.siteFile = {
188
- * '/favicon.ico': 'https://eggjs.org/favicon.png',
189
- * };
190
- * ```
191
- */
192
- config.siteFile = {
193
- enable: true,
194
- '/favicon.ico': pathToFileURL(path.join(import.meta.dirname, 'favicon.png')),
195
- // default cache in 30 days
196
- cacheControl: 'public, max-age=2592000',
197
- };
198
- /**
199
- * The options of `bodyParser` middleware
200
- *
201
- * @member Config#bodyParser
202
- * @property {Boolean} enable - enable bodyParser or not, default is true
203
- * @property {String | RegExp | Function | Array} ignore - won't parse request body when url path hit ignore pattern, can not set `ignore` when `match` presented
204
- * @property {String | RegExp | Function | Array} match - will parse request body only when url path hit match pattern
205
- * @property {String} encoding - body's encoding type,default is utf8
206
- * @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
207
- * @property {String} jsonLimit - limit of the json body, default is 1mb
208
- * @property {String} textLimit - limit of the text body, default is 1mb
209
- * @property {Boolean} strict - when set to true, JSON parser will only accept arrays and objects. Default is true
210
- * @property {Number} queryString.arrayLimit - urlencoded body array's max length, default is 100
211
- * @property {Number} queryString.depth - urlencoded body object's max depth, default is 5
212
- * @property {Number} queryString.parameterLimit - urlencoded body maximum parameters, default is 1000
213
- */
214
- config.bodyParser = {
215
- enable: true,
216
- encoding: 'utf8',
217
- formLimit: '1mb',
218
- jsonLimit: '1mb',
219
- textLimit: '1mb',
220
- strict: true,
221
- // @see https://github.com/hapijs/qs/blob/master/lib/parse.js#L8 for more options
222
- queryString: {
223
- arrayLimit: 100,
224
- depth: 5,
225
- parameterLimit: 1000,
226
- },
227
- onProtoPoisoning: 'error',
228
- onerror(err, ctx) {
229
- err.message = `${err.message}, check bodyParser config`;
230
- if (ctx.status === 404) {
231
- // set default status to 400, meaning client bad request
232
- ctx.status = 400;
233
- if (!err.status) {
234
- err.status = 400;
235
- }
236
- }
237
- throw err;
238
- },
239
- };
240
- /**
241
- * logger options
242
- * @member Config#logger
243
- * @property {String} dir - directory of log files
244
- * @property {String} encoding - log file encoding, defaults to utf8
245
- * @property {String} level - default log level, could be: DEBUG, INFO, WARN, ERROR or NONE, defaults to INFO in production
246
- * @property {String} consoleLevel - log level of stdout, defaults to INFO in local serverEnv, defaults to WARN in unittest, defaults to NONE elsewise
247
- * @property {Boolean} disableConsoleAfterReady - disable logger console after app ready. defaults to `false` on local and unittest env, others is `true`.
248
- * @property {Boolean} outputJSON - log as JSON or not, defaults to false
249
- * @property {Boolean} buffer - if enabled, flush logs to disk at a certain frequency to improve performance, defaults to true
250
- * @property {String} errorLogName - file name of errorLogger
251
- * @property {String} coreLogName - file name of coreLogger
252
- * @property {String} agentLogName - file name of agent worker log
253
- * @property {Object} coreLogger - custom config of coreLogger
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
- export default factory;
378
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmRlZmF1bHQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29uZmlnL2NvbmZpZy5kZWZhdWx0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sSUFBSSxNQUFNLFdBQVcsQ0FBQztBQUM3QixPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sVUFBVSxDQUFDO0FBRXpDLE9BQU8sRUFBRSxtQkFBbUIsRUFBZ0QsTUFBTSxhQUFhLENBQUM7QUFFaEc7Ozs7R0FJRztBQUNILE1BQU0sT0FBTyxHQUFxQixtQkFBbUIsQ0FBQyxDQUFDLE9BQU8sRUFBb0IsRUFBRTtJQUNsRixNQUFNLE1BQU0sR0FBcUI7UUFDL0I7Ozs7O1dBS0c7UUFDSCxHQUFHLEVBQUUsT0FBTyxDQUFDLEdBQUc7UUFFaEI7Ozs7O1dBS0c7UUFDSCxJQUFJLEVBQUUsT0FBTyxDQUFDLElBQUk7UUFFbEI7Ozs7OztXQU1HO1FBQ0gsSUFBSSxFQUFFLEVBQUU7UUFFUjs7Ozs7O1dBTUc7UUFDSCxPQUFPLEVBQUU7UUFDUCwwQkFBMEI7UUFDMUIsK0JBQStCO1NBQ2hDO1FBRUQ7Ozs7OztXQU1HO1FBQ0gsS0FBSyxFQUFFLEtBQUs7UUFFWjs7Ozs7Ozs7V0FRRztRQUNILFdBQVcsRUFBRSxDQUFDO1FBRWQ7Ozs7OztXQU1HO1FBQ0gsYUFBYSxFQUFFLENBQUM7UUFFaEI7Ozs7OztXQU1HO1FBQ0gsZUFBZSxFQUFFLG1CQUFtQjtRQUVwQzs7Ozs7O1dBTUc7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