egg 4.1.0-beta.20 → 4.1.0-beta.21

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