egg 4.1.0-beta.19 → 4.1.0-beta.20

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 (105) hide show
  1. package/dist/AgentWorkerLoader-DG_hAClt.d.ts +17 -0
  2. package/dist/AgentWorkerLoader-D_hceBRW.js +24 -0
  3. package/dist/AppWorkerLoader-CAtxJvGl.js +37 -0
  4. package/dist/AppWorkerLoader-CT875rYM.d.ts +22 -0
  5. package/dist/CookieLimitExceedError-CAW0HYJw.d.ts +8 -0
  6. package/dist/CookieLimitExceedError-DLGakbeu.js +15 -0
  7. package/dist/EggApplicationLoader-CMe1VQt1.js +7 -0
  8. package/dist/EggApplicationLoader-PnIvd5oV.d.ts +8 -0
  9. package/dist/IMessenger-C9g6ypSI.d.ts +54 -0
  10. package/dist/MessageUnhandledRejectionError-Lq5fWw24.d.ts +8 -0
  11. package/dist/MessageUnhandledRejectionError-oD_E1Ewl.js +15 -0
  12. package/dist/agent-BfFWeJj4.js +55 -0
  13. package/dist/agent.d.ts +11 -1
  14. package/dist/agent.js +1 -1
  15. package/dist/app/extend/context.d.ts +11 -182
  16. package/dist/app/extend/context.js +1 -242
  17. package/dist/app/extend/helper.d.ts +11 -41
  18. package/dist/app/extend/helper.js +3 -45
  19. package/dist/app/extend/request.d.ts +11 -135
  20. package/dist/app/extend/request.js +2 -224
  21. package/dist/app/extend/response.d.ts +1 -28
  22. package/dist/app/extend/response.js +1 -34
  23. package/dist/app/middleware/meta.d.ts +11 -10
  24. package/dist/app/middleware/notfound.d.ts +11 -10
  25. package/dist/app/middleware/site_file.d.ts +11 -12
  26. package/dist/application-DVwFQSa9.js +208 -0
  27. package/dist/base-KLVtlzUD.d.ts +12 -0
  28. package/dist/base_context_class-Xc1OZql9.js +19 -0
  29. package/dist/base_context_logger-CZU59PGA.js +58 -0
  30. package/dist/base_hook_class-D0Gu2p8r.js +26 -0
  31. package/dist/base_hook_class-R8A8gm1s.d.ts +1109 -0
  32. package/dist/config/config.default.d.ts +11 -2
  33. package/dist/config/config.default.js +26 -2
  34. package/dist/context-D1Wg7CXs.js +244 -0
  35. package/dist/context_httpclient-BpRMdJhf.js +29 -0
  36. package/dist/egg-DVo5e_lr.js +800 -0
  37. package/dist/error-BYo_LRnd.js +1 -0
  38. package/dist/helper-B3PKMPXq.js +47 -0
  39. package/dist/httpclient-C1QPc_R7.js +36 -0
  40. package/dist/index-CUPkUUOR.d.ts +1 -0
  41. package/dist/index-CkgLZdB4.d.ts +1 -0
  42. package/dist/index.d.ts +12 -20
  43. package/dist/index.js +26 -19
  44. package/dist/lib/agent.d.ts +11 -21
  45. package/dist/lib/agent.js +20 -54
  46. package/dist/lib/application.d.ts +11 -59
  47. package/dist/lib/application.js +21 -207
  48. package/dist/lib/core/base_context_class.d.ts +11 -22
  49. package/dist/lib/core/base_context_class.js +2 -17
  50. package/dist/lib/core/base_context_logger.d.ts +11 -39
  51. package/dist/lib/core/base_context_logger.js +1 -56
  52. package/dist/lib/core/base_hook_class.d.ts +11 -17
  53. package/dist/lib/core/base_hook_class.js +1 -24
  54. package/dist/lib/core/context_httpclient.d.ts +11 -21
  55. package/dist/lib/core/context_httpclient.js +1 -27
  56. package/dist/lib/core/httpclient.d.ts +12 -17
  57. package/dist/lib/core/httpclient.js +1 -34
  58. package/dist/lib/core/logger.d.ts +11 -1
  59. package/dist/lib/core/logger.js +1 -29
  60. package/dist/lib/core/messenger/IMessenger.d.ts +1 -53
  61. package/dist/lib/core/messenger/base.d.ts +12 -11
  62. package/dist/lib/core/messenger/base.js +15 -27
  63. package/dist/lib/core/messenger/index.d.ts +12 -11
  64. package/dist/lib/core/messenger/index.js +15 -11
  65. package/dist/lib/core/messenger/ipc.d.ts +12 -4
  66. package/dist/lib/core/messenger/ipc.js +15 -128
  67. package/dist/lib/core/messenger/local.d.ts +12 -4
  68. package/dist/lib/core/messenger/local.js +15 -124
  69. package/dist/lib/core/utils.js +1 -46
  70. package/dist/lib/egg.d.ts +12 -285
  71. package/dist/lib/egg.js +15 -518
  72. package/dist/lib/error/CookieLimitExceedError.d.ts +1 -7
  73. package/dist/lib/error/CookieLimitExceedError.js +1 -13
  74. package/dist/lib/error/MessageUnhandledRejectionError.d.ts +1 -7
  75. package/dist/lib/error/MessageUnhandledRejectionError.js +1 -13
  76. package/dist/lib/error/index.d.ts +3 -2
  77. package/dist/lib/error/index.js +3 -2
  78. package/dist/lib/loader/AgentWorkerLoader.d.ts +2 -16
  79. package/dist/lib/loader/AgentWorkerLoader.js +2 -22
  80. package/dist/lib/loader/AppWorkerLoader.d.ts +2 -21
  81. package/dist/lib/loader/AppWorkerLoader.js +2 -35
  82. package/dist/lib/loader/EggApplicationLoader.d.ts +1 -7
  83. package/dist/lib/loader/EggApplicationLoader.js +1 -5
  84. package/dist/lib/loader/index.d.ts +4 -3
  85. package/dist/lib/loader/index.js +4 -3
  86. package/dist/lib/start.d.ts +11 -27
  87. package/dist/lib/start.js +25 -34
  88. package/dist/lib/types.d.ts +12 -283
  89. package/dist/lib/types.js +2 -32
  90. package/dist/lib/types.plugin.d.ts +1 -12
  91. package/dist/lib/types.plugin.js +1 -12
  92. package/dist/lib/utils.js +1 -12
  93. package/dist/loader-3myZ-rpm.js +1 -0
  94. package/dist/logger-C4tIcO3S.js +31 -0
  95. package/dist/request-Cy_1DlaX.js +225 -0
  96. package/dist/response-CDeQ9Sx2.js +36 -0
  97. package/dist/response-DlNYDj00.d.ts +29 -0
  98. package/dist/src-BuOjXSrB.js +3 -0
  99. package/dist/start-4E84z796.js +35 -0
  100. package/dist/types-dKSyDnVp.js +32 -0
  101. package/dist/types.plugin-B2v0K0I8.js +14 -0
  102. package/dist/types.plugin-C3D5I7VD.d.ts +12 -0
  103. package/dist/utils-B1Rjsoi9.js +48 -0
  104. package/dist/utils-BDoYg6z6.js +14 -0
  105. package/package.json +22 -22
package/dist/lib/egg.js CHANGED
@@ -1,520 +1,17 @@
1
- import { BaseHookClass } from "./core/base_hook_class.js";
2
- import { BaseContextClass as BaseContextClass$1 } from "./core/base_context_class.js";
3
- import Context from "../app/extend/context.js";
4
- import Response from "../app/extend/response.js";
5
- import Request from "../app/extend/request.js";
6
- import { create } from "./core/messenger/index.js";
7
- import { ContextHttpClient } from "./core/context_httpclient.js";
8
- import { HttpClient } from "./core/httpclient.js";
9
- import { createLoggers } from "./core/logger.js";
10
- import { convertObject } from "./core/utils.js";
11
- import { getSourceDirname } from "./utils.js";
12
- import { EggCore, Router, utils } from "@eggjs/core";
13
- import path from "node:path";
14
- import { performance } from "node:perf_hooks";
15
- import fs from "node:fs";
16
- import http from "node:http";
17
- import inspector from "node:inspector";
18
- import { AsyncLocalStorage } from "node:async_hooks";
19
- import createClusterClient, { close } from "cluster-client";
20
- import { extend } from "@eggjs/extend2";
21
- import { EggContextLogger, EggLogger, EggLoggers } from "egg-logger";
22
- import { Cookies } from "@eggjs/cookies";
23
- import CircularJSON from "circular-json-for-egg";
1
+ import "../base_hook_class-D0Gu2p8r.js";
2
+ import "../base_context_logger-CZU59PGA.js";
3
+ import "../base_context_class-Xc1OZql9.js";
4
+ import { Context } from "../context-D1Wg7CXs.js";
5
+ import { Response } from "../response-CDeQ9Sx2.js";
6
+ import { Request } from "../request-Cy_1DlaX.js";
7
+ import "../CookieLimitExceedError-DLGakbeu.js";
8
+ import "../MessageUnhandledRejectionError-oD_E1Ewl.js";
9
+ import "../error-BYo_LRnd.js";
10
+ import { EggApplicationCore, Router } from "../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";
24
16
 
25
- //#region src/lib/egg.ts
26
- const EGG_PATH = Symbol.for("egg#eggPath");
27
- /**
28
- * Based on koa's Application
29
- * @see https://github.com/eggjs/egg-core
30
- * @see https://github.com/eggjs/koa/blob/master/src/application.ts
31
- * @augments EggCore
32
- */
33
- var EggApplicationCore = class extends EggCore {
34
- /**
35
- * Get the current request context from AsyncLocalStorage.
36
- * This provides access to the context object for the current request lifecycle.
37
- * @returns {Context | undefined} The current request context, or undefined if not in a request scope.
38
- */
39
- get currentContext() {
40
- return this.ctxStorage.getStore();
41
- }
42
- ContextCookies = Cookies;
43
- ContextLogger = EggContextLogger;
44
- ContextHttpClient = ContextHttpClient;
45
- HttpClient = HttpClient;
46
- HttpClientNext = HttpClient;
47
- /**
48
- * Retrieve base context class
49
- * @member {BaseContextClass} BaseContextClass
50
- * @since 1.0.0
51
- */
52
- BaseContextClass = BaseContextClass$1;
53
- /**
54
- * Retrieve base controller
55
- * @member {Controller} Controller
56
- * @since 1.0.0
57
- */
58
- Controller = BaseContextClass$1;
59
- /**
60
- * Retrieve base service
61
- * @member {Service} Service
62
- * @since 1.0.0
63
- */
64
- Service = BaseContextClass$1;
65
- /**
66
- * Retrieve base subscription
67
- * @member {Subscription} Subscription
68
- * @since 2.12.0
69
- */
70
- Subscription = BaseContextClass$1;
71
- /**
72
- * Retrieve base context class
73
- * @member {BaseHookClass} BaseHookClass
74
- */
75
- BaseHookClass = BaseHookClass;
76
- /**
77
- * Retrieve base boot
78
- * @member {Boot}
79
- * @alias BaseHookClass
80
- */
81
- Boot = BaseHookClass;
82
- #httpClient;
83
- #loggers;
84
- #clusterClients = [];
85
- messenger;
86
- agent;
87
- application;
88
- /**
89
- * @class
90
- * @param {Object} options
91
- * - {Object} [type] - type of instance, Agent and Application both extend koa, type can determine what it is.
92
- * - {String} [baseDir] - app root dir, default is `process.cwd()`
93
- * - {Object} [plugins] - custom plugin config, use it in unittest
94
- * - {String} [mode] - process mode, can be cluster / single, default is `cluster`
95
- */
96
- constructor(options) {
97
- options = {
98
- mode: "cluster",
99
- type: "application",
100
- baseDir: process.cwd(),
101
- ...options
102
- };
103
- super(options);
104
- /**
105
- * messenger instance
106
- * @member {Messenger}
107
- * @since 1.0.0
108
- */
109
- this.messenger = create(this);
110
- this.messenger.once("egg-ready", () => {
111
- this.lifecycle.triggerServerDidReady();
112
- });
113
- this.lifecycle.registerBeforeStart(async () => {
114
- await this.load();
115
- }, "load files");
116
- }
117
- /**
118
- * @deprecated please use `options` property instead
119
- */
120
- get _options() {
121
- return this.options;
122
- }
123
- async loadConfig() {
124
- await this.loader.loadConfig();
125
- }
126
- async load() {
127
- await this.loadConfig();
128
- this.ready(() => process.nextTick(() => {
129
- const dumpStartTime = Date.now();
130
- this.dumpConfig();
131
- this.dumpTiming();
132
- this.coreLogger.info("[egg] dump config after ready, %sms", Date.now() - dumpStartTime);
133
- }));
134
- this.#setupTimeoutTimer();
135
- this.console.info("[egg] App root: %s", this.baseDir);
136
- this.console.info("[egg] All *.log files save on %j", this.config.logger.dir);
137
- this.console.info("[egg] Loaded enabled plugin %j", this.loader.orderPlugins);
138
- this._unhandledRejectionHandler = this._unhandledRejectionHandler.bind(this);
139
- process.on("unhandledRejection", this._unhandledRejectionHandler);
140
- this.lifecycle.registerBeforeClose(async () => {
141
- for (const clusterClient of this.#clusterClients) await close(clusterClient);
142
- this.#clusterClients = [];
143
- if (this.type === "application" && this.options.mode === "single") await this.agent.close();
144
- for (const logger of this.loggers.values()) logger.close();
145
- this.messenger.close();
146
- process.removeListener("unhandledRejection", this._unhandledRejectionHandler);
147
- });
148
- await this.loader.load();
149
- }
150
- /**
151
- * Usage: new ApiClient({ cluster: app.cluster })
152
- */
153
- get cluster() {
154
- return this.clusterWrapper.bind(this);
155
- }
156
- /**
157
- * Wrap the Client with Leader/Follower Pattern
158
- *
159
- * @description almost the same as Agent.cluster API, the only different is that this method create Follower.
160
- *
161
- * @see https://github.com/node-modules/cluster-client
162
- * @param {Function} clientClass - client class function
163
- * @param {Object} [options]
164
- * - {Boolean} [autoGenerate] - whether generate delegate rule automatically, default is true
165
- * - {Function} [formatKey] - a method to transform the subscription info into a string,default is JSON.stringify
166
- * - {Object} [transcode|JSON.stringify/parse]
167
- * - {Function} encode - custom serialize method
168
- * - {Function} decode - custom deserialize method
169
- * - {Boolean} [isBroadcast] - whether broadcast subscription result to all followers or just one, default is true
170
- * - {Number} [responseTimeout] - response timeout, default is 3 seconds
171
- * - {Number} [maxWaitTime|30000] - leader startup max time, default is 30 seconds
172
- * @return {ClientWrapper} wrapper
173
- */
174
- clusterWrapper(clientClass, options) {
175
- const clientClassOptions = {
176
- ...this.config.clusterClient,
177
- ...options,
178
- singleMode: this.options.mode === "single",
179
- port: this.options.clusterPort,
180
- isLeader: this.type === "agent",
181
- logger: this.coreLogger,
182
- isCheckHeartbeat: this.config.env === "prod" ? true : inspector.url() === void 0
183
- };
184
- const client = createClusterClient(clientClass, clientClassOptions);
185
- this.#patchClusterClient(client);
186
- return client;
187
- }
188
- /**
189
- * print the information when console.log(app)
190
- * @return {Object} inspected app.
191
- * @since 1.0.0
192
- * @example
193
- * ```js
194
- * console.log(app);
195
- * =>
196
- * {
197
- * name: 'mock-app',
198
- * env: 'test',
199
- * subdomainOffset: 2,
200
- * config: '<egg config>',
201
- * controller: '<egg controller>',
202
- * service: '<egg service>',
203
- * middlewares: '<egg middlewares>',
204
- * urllib: '<egg urllib>',
205
- * loggers: '<egg loggers>'
206
- * }
207
- * ```
208
- */
209
- inspect() {
210
- const res = { env: this.config.env };
211
- function delegate(res$1, app, keys) {
212
- for (const key of keys) if (app[key]) res$1[key] = app[key];
213
- }
214
- function abbr(res$1, app, keys) {
215
- for (const key of keys) if (app[key]) res$1[key] = `<egg ${key}>`;
216
- }
217
- delegate(res, this, [
218
- "name",
219
- "baseDir",
220
- "subdomainOffset"
221
- ]);
222
- abbr(res, this, [
223
- "config",
224
- "controller",
225
- "httpclient",
226
- "loggers",
227
- "middlewares",
228
- "router",
229
- "serviceClasses"
230
- ]);
231
- return res;
232
- }
233
- toJSON() {
234
- return this.inspect();
235
- }
236
- /**
237
- * http request helper base on {@link httpclient}, it will auto save httpclient log.
238
- * Keep the same api with `httpclient.request(url, args)`.
239
- *
240
- * See https://github.com/node-modules/urllib#api-doc for more details.
241
- *
242
- * @param {String} url request url address.
243
- * @param {Object} options
244
- * - method {String} - Request method, defaults to GET. Could be GET, POST, DELETE or PUT. Alias 'type'.
245
- * - data {Object} - Data to be sent. Will be stringify automatically.
246
- * - dataType {String} - String - Type of response data. Could be `text` or `json`.
247
- * If it's `text`, the callback data would be a String.
248
- * If it's `json`, the data of callback would be a parsed JSON Object.
249
- * Default callback data would be a Buffer.
250
- * - headers {Object} - Request headers.
251
- * - timeout {Number} - Request timeout in milliseconds. Defaults to exports.TIMEOUT.
252
- * Include remote server connecting timeout and response timeout.
253
- * When timeout happen, will return ConnectionTimeout or ResponseTimeout.
254
- * - auth {String} - `username:password` used in HTTP Basic Authorization.
255
- * - followRedirect {Boolean} - follow HTTP 3xx responses as redirects. defaults to false.
256
- * - gzip {Boolean} - let you get the res object when request connected, default false. alias customResponse
257
- * - nestedQuerystring {Boolean} - urllib default use querystring to stringify form data which don't
258
- * support nested object, will use qs instead of querystring to support nested object by set this option to true.
259
- * - more options see https://github.com/node-modules/urllib
260
- * @return {Object}
261
- * - status {Number} - HTTP response status
262
- * - headers {Object} - HTTP response headers
263
- * - res {Object} - HTTP response meta
264
- * - data {Object} - HTTP response body
265
- *
266
- * @example
267
- * ```js
268
- * const result = await app.curl('http://example.com/foo.json', {
269
- * method: 'GET',
270
- * dataType: 'json',
271
- * });
272
- * console.log(result.status, result.headers, result.data);
273
- * ```
274
- */
275
- async curl(url, options) {
276
- return await this.httpClient.request(url, options);
277
- }
278
- /**
279
- * Create a new HttpClient instance with custom options
280
- * @param {Object} [options] HttpClient init options
281
- */
282
- createHttpClient(options) {
283
- return new this.HttpClient(this, options);
284
- }
285
- /**
286
- * HttpClient instance
287
- * @see https://github.com/node-modules/urllib
288
- * @member {HttpClient}
289
- */
290
- get httpClient() {
291
- if (!this.#httpClient) this.#httpClient = this.createHttpClient();
292
- return this.#httpClient;
293
- }
294
- /**
295
- * @deprecated please use httpClient instead
296
- * @alias httpClient
297
- * @member {HttpClient}
298
- */
299
- get httpclient() {
300
- return this.httpClient;
301
- }
302
- /**
303
- * All loggers contain logger, coreLogger and customLogger
304
- * @member {Object}
305
- * @since 1.0.0
306
- */
307
- get loggers() {
308
- if (!this.#loggers) this.#loggers = createLoggers(this);
309
- return this.#loggers;
310
- }
311
- /**
312
- * Get logger by name, it's equal to app.loggers['name'],
313
- * but you can extend it with your own logical.
314
- * @param {String} name - logger name
315
- * @return {Logger} logger
316
- */
317
- getLogger(name) {
318
- return this.loggers[name] || null;
319
- }
320
- /**
321
- * application logger, log file is `$HOME/logs/{appname}/{appname}-web`
322
- * @member {Logger}
323
- * @since 1.0.0
324
- */
325
- get logger() {
326
- return this.getLogger("logger");
327
- }
328
- /**
329
- * core logger for framework and plugins, log file is `$HOME/logs/{appname}/egg-web`
330
- * @member {Logger}
331
- * @since 1.0.0
332
- */
333
- get coreLogger() {
334
- return this.getLogger("coreLogger");
335
- }
336
- _unhandledRejectionHandler(err) {
337
- this.coreLogger.error("[egg:unhandledRejection] %s", err && err.message || err);
338
- if (!(err instanceof Error)) {
339
- const newError = new Error(String(err));
340
- if (err) {
341
- if (err.name) newError.name = err.name;
342
- if (err.message) newError.message = err.message;
343
- if (err.stack) newError.stack = err.stack;
344
- }
345
- err = newError;
346
- }
347
- if (err.name === "Error") err.name = "unhandledRejectionError";
348
- this.coreLogger.error(err);
349
- }
350
- /**
351
- * dump out the config and meta object
352
- * @private
353
- */
354
- dumpConfigToObject() {
355
- let ignoreList;
356
- try {
357
- ignoreList = Array.from(this.config.dump.ignore);
358
- } catch {
359
- ignoreList = [];
360
- }
361
- const config = extend(true, {}, {
362
- config: this.config,
363
- plugins: this.loader.allPlugins,
364
- appInfo: this.loader.appInfo
365
- });
366
- convertObject(config, ignoreList);
367
- return {
368
- config,
369
- meta: this.loader.configMeta
370
- };
371
- }
372
- /**
373
- * save app.config to `run/${type}_config.json`
374
- * @private
375
- */
376
- dumpConfig() {
377
- const rundir = this.config.rundir;
378
- try {
379
- if (!fs.existsSync(rundir)) fs.mkdirSync(rundir);
380
- const { config, meta } = this.dumpConfigToObject();
381
- const dumpFile = path.join(rundir, `${this.type}_config.json`);
382
- fs.writeFileSync(dumpFile, CircularJSON.stringify(config, null, 2));
383
- const dumpMetaFile = path.join(rundir, `${this.type}_config_meta.json`);
384
- fs.writeFileSync(dumpMetaFile, CircularJSON.stringify(meta, null, 2));
385
- } catch (err) {
386
- this.coreLogger.warn(`[egg] dumpConfig error: ${err.message}`);
387
- }
388
- }
389
- dumpTiming() {
390
- try {
391
- const items = this.timing.toJSON();
392
- const rundir = this.config.rundir;
393
- const dumpFile = path.join(rundir, `${this.type}_timing_${process.pid}.json`);
394
- fs.writeFileSync(dumpFile, CircularJSON.stringify(items, null, 2));
395
- this.coreLogger.info(this.timing.toString());
396
- this.timing.disable();
397
- for (const item of items) if (item.index > 0 && item.duration && item.duration >= this.config.dump.timing.slowBootActionMinDuration) this.coreLogger.warn("[egg][dumpTiming][slow-boot-action] #%d %dms, name: %s", item.index, item.duration, item.name);
398
- } catch (err) {
399
- this.coreLogger.warn(`[egg] dumpTiming error: ${err.message}`);
400
- }
401
- }
402
- get [EGG_PATH]() {
403
- return getSourceDirname();
404
- }
405
- #setupTimeoutTimer() {
406
- const startTimeoutTimer = setTimeout(() => {
407
- this.coreLogger.error(this.timing.toString());
408
- this.coreLogger.error(`${this.type} still doesn't ready after ${this.config.workerStartTimeout} ms.`);
409
- const items = this.timing.toJSON();
410
- for (const item of items) {
411
- if (item.end) continue;
412
- this.coreLogger.error(`unfinished timing item: ${CircularJSON.stringify(item)}`);
413
- }
414
- this.coreLogger.error("[egg][setupTimeoutTimer] check run/%s_timing_%s.json for more details.", this.type, process.pid);
415
- this.emit("startTimeout");
416
- this.dumpConfig();
417
- this.dumpTiming();
418
- }, this.config.workerStartTimeout);
419
- this.ready(() => clearTimeout(startTimeoutTimer));
420
- }
421
- get config() {
422
- return super.config;
423
- }
424
- /**
425
- * app.env delegate app.config.env
426
- * @deprecated
427
- */
428
- get env() {
429
- this.deprecate("please use app.config.env instead");
430
- return this.config.env;
431
- }
432
- set env(_) {}
433
- /**
434
- * app.proxy delegate app.config.proxy
435
- * @deprecated
436
- */
437
- get proxy() {
438
- return this.config.proxy;
439
- }
440
- set proxy(_) {}
441
- #patchClusterClient(client) {
442
- const rawCreate = client.create;
443
- client.create = (...args) => {
444
- const realClient = rawCreate.apply(client, args);
445
- this.#clusterClients.push(realClient);
446
- return realClient;
447
- };
448
- }
449
- /**
450
- * Create an anonymous context, the context isn't request level, so the request is mocked.
451
- * then you can use context level API like `ctx.service`
452
- * @member {String} EggApplication#createAnonymousContext
453
- * @param {Request} [req] - if you want to mock request like querystring, you can pass an object to this function.
454
- * @return {Context} context
455
- */
456
- createAnonymousContext(req) {
457
- const request = {
458
- headers: {
459
- host: "127.0.0.1",
460
- "x-forwarded-for": "127.0.0.1"
461
- },
462
- query: {},
463
- querystring: "",
464
- host: "127.0.0.1",
465
- hostname: "127.0.0.1",
466
- protocol: "http",
467
- secure: "false",
468
- method: "GET",
469
- url: "/",
470
- path: "/",
471
- socket: {
472
- remoteAddress: "127.0.0.1",
473
- remotePort: 7001
474
- }
475
- };
476
- if (req) for (const key in req) if (key === "headers" || key === "query" || key === "socket") Object.assign(request[key], req[key]);
477
- else request[key] = req[key];
478
- const response = new http.ServerResponse(request);
479
- return this.createContext(request, response);
480
- }
481
- /**
482
- * Run async function in the anonymous context scope
483
- * @see Context#runInAnonymousContextScope
484
- * @param {Function} scope - the first args is an anonymous ctx, scope should be async function
485
- * @param {Request} [req] - if you want to mock request like querystring, you can pass an object to this function.
486
- */
487
- async runInAnonymousContextScope(scope, req) {
488
- const ctx = this.createAnonymousContext(req);
489
- if (!scope.name) Reflect.set(scope, "_name", utils.getCalleeFromStack(true));
490
- return await this.ctxStorage.run(ctx, async () => {
491
- return await scope(ctx);
492
- });
493
- }
494
- /**
495
- * Create egg context
496
- * @function EggApplication#createContext
497
- * @param {Req} req - node native Request object
498
- * @param {Res} res - node native Response object
499
- * @return {Context} context object
500
- */
501
- createContext(req, res) {
502
- const context = Object.create(this.context);
503
- const request = context.request = Object.create(this.request);
504
- const response = context.response = Object.create(this.response);
505
- context.app = request.app = response.app = this;
506
- context.req = request.req = response.req = req;
507
- context.res = request.res = response.res = res;
508
- request.ctx = response.ctx = context;
509
- request.response = response;
510
- response.request = request;
511
- context.onerror = context.onerror.bind(context);
512
- context.originalUrl = request.originalUrl = req.url;
513
- context.starttime = Date.now();
514
- context.performanceStarttime = performance.now();
515
- return context;
516
- }
517
- };
518
-
519
- //#endregion
520
17
  export { Context, EggApplicationCore, Request, Response, Router };
@@ -1,8 +1,2 @@
1
- //#region src/lib/error/CookieLimitExceedError.d.ts
2
- declare class CookieLimitExceedError extends Error {
3
- key: string;
4
- cookie: string;
5
- constructor(key: string, cookie: string);
6
- }
7
- //#endregion
1
+ import { CookieLimitExceedError } from "../../CookieLimitExceedError-CAW0HYJw.js";
8
2
  export { CookieLimitExceedError };
@@ -1,15 +1,3 @@
1
- //#region src/lib/error/CookieLimitExceedError.ts
2
- var CookieLimitExceedError = class extends Error {
3
- key;
4
- cookie;
5
- constructor(key, cookie) {
6
- super(`cookie ${key}'s length(${cookie.length}) exceed the limit(4093)`);
7
- this.name = this.constructor.name;
8
- this.key = key;
9
- this.cookie = cookie;
10
- Error.captureStackTrace(this, this.constructor);
11
- }
12
- };
1
+ import { CookieLimitExceedError } from "../../CookieLimitExceedError-DLGakbeu.js";
13
2
 
14
- //#endregion
15
3
  export { CookieLimitExceedError };
@@ -1,8 +1,2 @@
1
- //#region src/lib/error/MessageUnhandledRejectionError.d.ts
2
- declare class MessageUnhandledRejectionError extends Error {
3
- event: string | symbol;
4
- args: any[];
5
- constructor(err: Error, event: string | symbol, ...args: any[]);
6
- }
7
- //#endregion
1
+ import { MessageUnhandledRejectionError } from "../../MessageUnhandledRejectionError-Lq5fWw24.js";
8
2
  export { MessageUnhandledRejectionError };
@@ -1,15 +1,3 @@
1
- //#region src/lib/error/MessageUnhandledRejectionError.ts
2
- var MessageUnhandledRejectionError = class extends Error {
3
- event;
4
- args;
5
- constructor(err, event, ...args) {
6
- super(`event: ${String(event)}, error: ${err.message}`, { cause: err });
7
- this.name = this.constructor.name;
8
- this.event = event;
9
- this.args = args;
10
- Error.captureStackTrace(this, this.constructor);
11
- }
12
- };
1
+ import { MessageUnhandledRejectionError } from "../../MessageUnhandledRejectionError-oD_E1Ewl.js";
13
2
 
14
- //#endregion
15
3
  export { MessageUnhandledRejectionError };
@@ -1,3 +1,4 @@
1
- import { CookieLimitExceedError } from "./CookieLimitExceedError.js";
2
- import { MessageUnhandledRejectionError } from "./MessageUnhandledRejectionError.js";
1
+ import { CookieLimitExceedError } from "../../CookieLimitExceedError-CAW0HYJw.js";
2
+ import { MessageUnhandledRejectionError } from "../../MessageUnhandledRejectionError-Lq5fWw24.js";
3
+ import "../../index-CkgLZdB4.js";
3
4
  export { CookieLimitExceedError, MessageUnhandledRejectionError };
@@ -1,4 +1,5 @@
1
- import { CookieLimitExceedError } from "./CookieLimitExceedError.js";
2
- import { MessageUnhandledRejectionError } from "./MessageUnhandledRejectionError.js";
1
+ import { CookieLimitExceedError } from "../../CookieLimitExceedError-DLGakbeu.js";
2
+ import { MessageUnhandledRejectionError } from "../../MessageUnhandledRejectionError-oD_E1Ewl.js";
3
+ import "../../error-BYo_LRnd.js";
3
4
 
4
5
  export { CookieLimitExceedError, MessageUnhandledRejectionError };
@@ -1,17 +1,3 @@
1
- import { EggApplicationLoader } from "./EggApplicationLoader.js";
2
-
3
- //#region src/lib/loader/AgentWorkerLoader.d.ts
4
-
5
- /**
6
- * Agent worker process loader
7
- * @see https://github.com/eggjs/egg-core/blob/master/src/loader/egg_loader.ts
8
- */
9
- declare class AgentWorkerLoader extends EggApplicationLoader {
10
- /**
11
- * loadPlugin first, then loadConfig
12
- */
13
- loadConfig(): Promise<void>;
14
- load(): Promise<void>;
15
- }
16
- //#endregion
1
+ import "../../EggApplicationLoader-PnIvd5oV.js";
2
+ import { AgentWorkerLoader } from "../../AgentWorkerLoader-DG_hAClt.js";
17
3
  export { AgentWorkerLoader };
@@ -1,24 +1,4 @@
1
- import { EggApplicationLoader } from "./EggApplicationLoader.js";
1
+ import "../../EggApplicationLoader-CMe1VQt1.js";
2
+ import { AgentWorkerLoader } from "../../AgentWorkerLoader-D_hceBRW.js";
2
3
 
3
- //#region src/lib/loader/AgentWorkerLoader.ts
4
- /**
5
- * Agent worker process loader
6
- * @see https://github.com/eggjs/egg-core/blob/master/src/loader/egg_loader.ts
7
- */
8
- var AgentWorkerLoader = class extends EggApplicationLoader {
9
- /**
10
- * loadPlugin first, then loadConfig
11
- */
12
- async loadConfig() {
13
- await this.loadPlugin();
14
- await super.loadConfig();
15
- }
16
- async load() {
17
- await this.loadAgentExtend();
18
- await this.loadContextExtend();
19
- await this.loadCustomAgent();
20
- }
21
- };
22
-
23
- //#endregion
24
4
  export { AgentWorkerLoader };
@@ -1,22 +1,3 @@
1
- import { EggApplicationLoader } from "./EggApplicationLoader.js";
2
-
3
- //#region src/lib/loader/AppWorkerLoader.d.ts
4
-
5
- /**
6
- * App worker process Loader, will load plugins
7
- * @see https://github.com/eggjs/egg-core/blob/master/src/loader/egg_loader.ts
8
- */
9
- declare class AppWorkerLoader extends EggApplicationLoader {
10
- /**
11
- * loadPlugin first, then loadConfig
12
- * @since 1.0.0
13
- */
14
- loadConfig(): Promise<void>;
15
- /**
16
- * Load all directories in convention
17
- * @since 1.0.0
18
- */
19
- load(): Promise<void>;
20
- }
21
- //#endregion
1
+ import "../../EggApplicationLoader-PnIvd5oV.js";
2
+ import { AppWorkerLoader } from "../../AppWorkerLoader-CT875rYM.js";
22
3
  export { AppWorkerLoader };