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
@@ -1,130 +1,17 @@
1
- import { BaseMessenger } from "./base.js";
2
- import { debuglog } from "node:util";
3
- import workerThreads from "node:worker_threads";
4
- import { sendmessage } from "sendmessage";
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 { Messenger } 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";
5
16
 
6
- //#region src/lib/core/messenger/ipc.ts
7
- const debug = debuglog("egg/lib/core/messenger/ipc");
8
- /**
9
- * Communication between app worker and agent worker by IPC channel
10
- */
11
- var Messenger = class extends BaseMessenger {
12
- pid;
13
- opids = [];
14
- constructor(egg) {
15
- super(egg);
16
- this.pid = String(process.pid);
17
- this.on("egg-pids", (workerIds) => {
18
- debug("[%s:%s] got egg-pids %j", this.egg.type, this.pid, workerIds);
19
- this.opids = workerIds.map((workerId) => String(workerId));
20
- });
21
- this.onMessage = this.onMessage.bind(this);
22
- if (this.egg.options.mode === "all-in-one-process") process.on("sendmessage-to-self", this.onMessage);
23
- else process.on("message", this.onMessage);
24
- if (!workerThreads.isMainThread) workerThreads.parentPort.on("message", this.onMessage);
25
- }
26
- /**
27
- * Send message to all agent and app
28
- * @param {String} action - message key
29
- * @param {Object} data - message value
30
- * @return {Messenger} this
31
- */
32
- broadcast(action, data) {
33
- debug("[%s:%s] broadcast %s with %j", this.egg.type, this.pid, action, data);
34
- this.send(action, data, "app");
35
- this.send(action, data, "agent");
36
- return this;
37
- }
38
- /**
39
- * send message to the specified process
40
- * @param {String} workerId - the workerId of the receiver
41
- * @param {String} action - message key
42
- * @param {Object} data - message value
43
- * @return {Messenger} this
44
- */
45
- sendTo(workerId, action, data) {
46
- debug("[%s:%s] send %s with %j to workerId:%s", this.egg.type, this.pid, action, data, workerId);
47
- const message = {
48
- action,
49
- data,
50
- receiverPid: String(workerId),
51
- receiverWorkerId: String(workerId)
52
- };
53
- this.#sendMessage(message);
54
- return this;
55
- }
56
- /**
57
- * send message to one app worker by random
58
- * - if it's running in agent, it will send to one of app workers
59
- * - if it's running in app, it will send to agent
60
- * @param {String} action - message key
61
- * @param {Object} data - message value
62
- * @return {Messenger} this
63
- */
64
- sendRandom(action, data) {
65
- if (this.opids.length === 0) {
66
- debug("[%s:%s] no pids, ignore sendRandom %s with %j", this.egg.type, this.pid, action, data);
67
- return this;
68
- }
69
- const index = Math.floor(Math.random() * this.opids.length);
70
- const workerId = this.opids[index];
71
- this.sendTo(workerId, action, data);
72
- return this;
73
- }
74
- /**
75
- * send message to app
76
- * @param {String} action - message key
77
- * @param {Object} data - message value
78
- * @return {Messenger} this
79
- */
80
- sendToApp(action, data) {
81
- debug("[%s:%s] send %s with %j to all app", this.egg.type, this.pid, action, data);
82
- this.send(action, data, "app");
83
- return this;
84
- }
85
- /**
86
- * send message to agent
87
- * @param {String} action - message key
88
- * @param {Object} data - message value
89
- * @return {Messenger} this
90
- */
91
- sendToAgent(action, data) {
92
- debug("[%s:%s] send %s with %j to all agent", this.egg.type, this.pid, action, data);
93
- this.send(action, data, "agent");
94
- return this;
95
- }
96
- /**
97
- * @param {String} action - message key
98
- * @param {Object} data - message value
99
- * @param {String} to - let master know how to send message
100
- * @return {Messenger} this
101
- */
102
- send(action, data, to) {
103
- debug("send message %s with %j to %s", action, data, to);
104
- this.#sendMessage({
105
- action,
106
- data,
107
- to
108
- });
109
- return this;
110
- }
111
- #sendMessage(message) {
112
- debug("[%s:%s] send message %j, mode: %s", this.egg.type, this.pid, message, this.egg.options.mode);
113
- if (this.egg.options.mode === "all-in-one-process") process.emit("sendmessage-to-self", message);
114
- else sendmessage(process, message);
115
- }
116
- onMessage(message) {
117
- if (typeof message?.action === "string") {
118
- debug("[%s:%s] got message %s with %j, receiverWorkerId: %s", this.egg.type, this.pid, message.action, message.data, message.receiverWorkerId ?? message.receiverPid);
119
- this.emit(message.action, message.data);
120
- } else if (message?.type === "Buffer") debug("[%s:%s] got an invalid message: %s", this.egg.type, this.pid, Buffer.from(message.data));
121
- else debug("[%s:%s] got an invalid message %j", this.egg.type, this.pid, message);
122
- }
123
- close() {
124
- process.removeListener("message", this.onMessage);
125
- this.removeAllListeners();
126
- }
127
- };
128
-
129
- //#endregion
130
17
  export { Messenger };
@@ -1,9 +1,17 @@
1
- import { IMessenger } from "./IMessenger.js";
2
- import { EggApplicationCore } from "../../egg.js";
3
- import { BaseMessenger } from "./base.js";
1
+ import "../../../EggApplicationLoader-PnIvd5oV.js";
2
+ import "../../../AppWorkerLoader-CT875rYM.js";
3
+ import "../../../AgentWorkerLoader-DG_hAClt.js";
4
+ import "../../../index-CUPkUUOR.js";
5
+ import { EggApplicationCore } from "../../../base_hook_class-R8A8gm1s.js";
6
+ import "../../../response-DlNYDj00.js";
7
+ import "../../../types.plugin-C3D5I7VD.js";
8
+ import { IMessenger } from "../../../IMessenger-C9g6ypSI.js";
9
+ import "../../../CookieLimitExceedError-CAW0HYJw.js";
10
+ import "../../../MessageUnhandledRejectionError-Lq5fWw24.js";
11
+ import "../../../index-CkgLZdB4.js";
12
+ import { BaseMessenger } from "../../../base-KLVtlzUD.js";
4
13
 
5
14
  //#region src/lib/core/messenger/local.d.ts
6
-
7
15
  /**
8
16
  * Communication between app worker and agent worker with EventEmitter
9
17
  */
@@ -1,126 +1,17 @@
1
- import { BaseMessenger } from "./base.js";
2
- import { debuglog } from "node:util";
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 { Messenger$1 as Messenger } 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";
3
16
 
4
- //#region src/lib/core/messenger/local.ts
5
- const debug = debuglog("egg/lib/core/messenger/local");
6
- /**
7
- * Communication between app worker and agent worker with EventEmitter
8
- */
9
- var Messenger = class extends BaseMessenger {
10
- pid;
11
- constructor(egg) {
12
- super(egg);
13
- this.pid = String(process.pid);
14
- }
15
- /**
16
- * Send message to all agent and app
17
- * @param {String} action - message key
18
- * @param {Object} data - message value
19
- * @return {Messenger} this
20
- */
21
- broadcast(action, data) {
22
- debug("[%s:%s] broadcast %s with %j", this.egg.type, this.pid, action, data);
23
- this.send(action, data, "both");
24
- return this;
25
- }
26
- /**
27
- * send message to the specified process
28
- * Notice: in single process mode, it only can send to self process,
29
- * and it will send to both agent and app's messengers.
30
- * @param {String} workerId - the workerId of the receiver
31
- * @param {String} action - message key
32
- * @param {Object} data - message value
33
- * @return {Messenger} this
34
- */
35
- sendTo(workerId, action, data) {
36
- debug("[%s:%s] send %s with %j to %s", this.egg.type, this.pid, action, data, workerId);
37
- if (String(workerId) !== this.pid) return this;
38
- this.send(action, data, "both");
39
- return this;
40
- }
41
- /**
42
- * send message to one worker by random
43
- * Notice: in single process mode, we only start one agent worker and one app worker
44
- * - if it's running in agent, it will send to one of app workers
45
- * - if it's running in app, it will send to agent
46
- * @param {String} action - message key
47
- * @param {Object} data - message value
48
- * @return {Messenger} this
49
- */
50
- sendRandom(action, data) {
51
- debug("[%s:%s] send %s with %j to opposite", this.egg.type, this.pid, action, data);
52
- this.send(action, data, "opposite");
53
- return this;
54
- }
55
- /**
56
- * send message to app
57
- * @param {String} action - message key
58
- * @param {Object} data - message value
59
- * @return {Messenger} this
60
- */
61
- sendToApp(action, data) {
62
- debug("[%s:%s] send %s with %j to all app", this.egg.type, this.pid, action, data);
63
- this.send(action, data, "application");
64
- return this;
65
- }
66
- /**
67
- * send message to agent
68
- * @param {String} action - message key
69
- * @param {Object} data - message value
70
- * @return {Messenger} this
71
- */
72
- sendToAgent(action, data) {
73
- debug("[%s:%s] send %s with %j to all agent", this.egg.type, this.pid, action, data);
74
- this.send(action, data, "agent");
75
- return this;
76
- }
77
- /**
78
- * @param {String} action - message key
79
- * @param {Object} data - message value
80
- * @param {String} to - let master know how to send message
81
- * @return {Messenger} this
82
- */
83
- send(action, data, to) {
84
- process.nextTick(() => {
85
- const { egg } = this;
86
- let application;
87
- let agent;
88
- let opposite;
89
- if (egg.type === "application") {
90
- application = egg;
91
- agent = egg.agent;
92
- opposite = agent;
93
- } else {
94
- agent = egg;
95
- application = egg.application;
96
- opposite = application;
97
- }
98
- if (!to) to = egg.type === "application" ? "agent" : "application";
99
- if (application && application.messenger && (to === "application" || to === "both")) application.messenger.onMessage({
100
- action,
101
- data
102
- });
103
- if (agent && agent.messenger && (to === "agent" || to === "both")) agent.messenger.onMessage({
104
- action,
105
- data
106
- });
107
- if (opposite && opposite.messenger && to === "opposite") opposite.messenger.onMessage({
108
- action,
109
- data
110
- });
111
- });
112
- return this;
113
- }
114
- onMessage(message) {
115
- if (typeof message?.action === "string") {
116
- debug("[%s:%s] got message %s with %j", this.egg.type, this.pid, message.action, message.data);
117
- this.emit(message.action, message.data);
118
- } else debug("[%s:%s] got an invalid message %j", this.egg.type, this.pid, message);
119
- }
120
- close() {
121
- this.removeAllListeners();
122
- }
123
- };
124
-
125
- //#endregion
126
17
  export { Messenger };
@@ -1,48 +1,3 @@
1
- import util from "node:util";
2
- import { isAsyncFunction, isClass, isFunction, isGeneratorFunction, isPrimitive, isRegExp, isSymbol } from "is-type-of";
1
+ import { convertObject, safeParseURL } from "../../utils-B1Rjsoi9.js";
3
2
 
4
- //#region src/lib/core/utils.ts
5
- function convertObject(obj, ignore = []) {
6
- if (!Array.isArray(ignore)) ignore = [ignore];
7
- for (const key of Object.keys(obj)) obj[key] = convertValue(key, obj[key], ignore);
8
- return obj;
9
- }
10
- function convertValue(key, value, ignore) {
11
- if (value === null || value === void 0) return value;
12
- let hit = false;
13
- for (const matchKey of ignore) if (typeof matchKey === "string" && matchKey === key) {
14
- hit = true;
15
- break;
16
- } else if (isRegExp(matchKey) && matchKey.test(key)) {
17
- hit = true;
18
- break;
19
- }
20
- if (!hit) {
21
- if (isSymbol(value) || isRegExp(value) || value instanceof URL) return value.toString();
22
- if (isPrimitive(value) || Array.isArray(value)) return value;
23
- }
24
- if (Object.getPrototypeOf(value) === Object.prototype) return convertObject(value, ignore);
25
- const name = value.name || "anonymous";
26
- if (isClass(value)) return `<Class ${name}>`;
27
- if (isFunction(value)) {
28
- if (isGeneratorFunction(value)) return `<GeneratorFunction ${name}>`;
29
- if (isAsyncFunction(value)) return `<AsyncFunction ${name}>`;
30
- return `<Function ${name}>`;
31
- }
32
- const typeName = value.constructor.name;
33
- if (typeName) {
34
- if (Buffer.isBuffer(value) || typeof value === "string") return `<${typeName} len: ${value.length}>`;
35
- return `<${typeName}>`;
36
- }
37
- return util.format(value);
38
- }
39
- function safeParseURL(url) {
40
- try {
41
- return new URL(url);
42
- } catch {
43
- return null;
44
- }
45
- }
46
-
47
- //#endregion
48
3
  export { convertObject, safeParseURL };
package/dist/lib/egg.d.ts CHANGED
@@ -1,285 +1,12 @@
1
- import { EggApplicationLoader } from "./loader/EggApplicationLoader.js";
2
- import { Agent } from "./agent.js";
3
- import { Application } from "./application.js";
4
- import { EggContextHttpClient as HttpClient, HttpClientOptions, HttpClientRequestOptions, HttpClientRequestURL, HttpClientResponse } from "./core/httpclient.js";
5
- import Response from "../app/extend/response.js";
6
- import Request from "../app/extend/request.js";
7
- import Context from "../app/extend/context.js";
8
- import { EggAppConfig as EggAppConfig$1 } from "./types.js";
9
- import { IMessenger } from "./core/messenger/IMessenger.js";
10
- import { ContextHttpClient } from "./core/context_httpclient.js";
11
- import { BaseContextClass as BaseContextClass$1 } from "./core/base_context_class.js";
12
- import { BaseHookClass } from "./core/base_hook_class.js";
13
- import { EggCore, EggCoreOptions, ILifecycleBoot, MiddlewareFunc as MiddlewareFunc$1, Next, Router } from "@eggjs/core";
14
- import { IncomingMessage, ServerResponse } from "node:http";
15
- import { AsyncLocalStorage } from "node:async_hooks";
16
- import { EggContextLogger, EggLogger, EggLoggers } from "egg-logger";
17
- import { Cookies } from "@eggjs/cookies";
18
-
19
- //#region src/lib/egg.d.ts
20
- declare const EGG_PATH: unique symbol;
21
- interface EggApplicationCoreOptions extends Omit<EggCoreOptions, 'baseDir'> {
22
- mode?: 'cluster' | 'single' | 'all-in-one-process';
23
- clusterPort?: number;
24
- baseDir?: string;
25
- }
26
- type EggContext = Context;
27
- type MiddlewareFunc<T extends Context = Context> = MiddlewareFunc$1<T>;
28
- /**
29
- * Based on koa's Application
30
- * @see https://github.com/eggjs/egg-core
31
- * @see https://github.com/eggjs/koa/blob/master/src/application.ts
32
- * @augments EggCore
33
- */
34
- declare class EggApplicationCore extends EggCore {
35
- #private;
36
- ctxStorage: AsyncLocalStorage<Context>;
37
- /**
38
- * Get the current request context from AsyncLocalStorage.
39
- * This provides access to the context object for the current request lifecycle.
40
- * @returns {Context | undefined} The current request context, or undefined if not in a request scope.
41
- */
42
- get currentContext(): Context | undefined;
43
- ContextCookies: typeof Cookies;
44
- ContextLogger: typeof EggContextLogger;
45
- ContextHttpClient: typeof ContextHttpClient;
46
- HttpClient: typeof HttpClient;
47
- HttpClientNext: typeof HttpClient;
48
- /**
49
- * Retrieve base context class
50
- * @member {BaseContextClass} BaseContextClass
51
- * @since 1.0.0
52
- */
53
- BaseContextClass: typeof BaseContextClass$1;
54
- /**
55
- * Retrieve base controller
56
- * @member {Controller} Controller
57
- * @since 1.0.0
58
- */
59
- Controller: typeof BaseContextClass$1;
60
- /**
61
- * Retrieve base service
62
- * @member {Service} Service
63
- * @since 1.0.0
64
- */
65
- Service: typeof BaseContextClass$1;
66
- /**
67
- * Retrieve base subscription
68
- * @member {Subscription} Subscription
69
- * @since 2.12.0
70
- */
71
- Subscription: typeof BaseContextClass$1;
72
- /**
73
- * Retrieve base context class
74
- * @member {BaseHookClass} BaseHookClass
75
- */
76
- BaseHookClass: typeof BaseHookClass;
77
- /**
78
- * Retrieve base boot
79
- * @member {Boot}
80
- * @alias BaseHookClass
81
- */
82
- Boot: typeof BaseHookClass;
83
- options: Required<EggApplicationCoreOptions>;
84
- readonly messenger: IMessenger;
85
- agent?: Agent;
86
- application?: Application;
87
- loader: EggApplicationLoader;
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?: EggApplicationCoreOptions);
97
- /**
98
- * @deprecated please use `options` property instead
99
- */
100
- get _options(): Required<EggApplicationCoreOptions>;
101
- protected loadConfig(): Promise<void>;
102
- protected load(): Promise<void>;
103
- /**
104
- * Usage: new ApiClient({ cluster: app.cluster })
105
- */
106
- get cluster(): (clientClass: unknown, options?: object) => any;
107
- /**
108
- * Wrap the Client with Leader/Follower Pattern
109
- *
110
- * @description almost the same as Agent.cluster API, the only different is that this method create Follower.
111
- *
112
- * @see https://github.com/node-modules/cluster-client
113
- * @param {Function} clientClass - client class function
114
- * @param {Object} [options]
115
- * - {Boolean} [autoGenerate] - whether generate delegate rule automatically, default is true
116
- * - {Function} [formatKey] - a method to transform the subscription info into a string,default is JSON.stringify
117
- * - {Object} [transcode|JSON.stringify/parse]
118
- * - {Function} encode - custom serialize method
119
- * - {Function} decode - custom deserialize method
120
- * - {Boolean} [isBroadcast] - whether broadcast subscription result to all followers or just one, default is true
121
- * - {Number} [responseTimeout] - response timeout, default is 3 seconds
122
- * - {Number} [maxWaitTime|30000] - leader startup max time, default is 30 seconds
123
- * @return {ClientWrapper} wrapper
124
- */
125
- clusterWrapper(clientClass: unknown, options?: object): any;
126
- /**
127
- * print the information when console.log(app)
128
- * @return {Object} inspected app.
129
- * @since 1.0.0
130
- * @example
131
- * ```js
132
- * console.log(app);
133
- * =>
134
- * {
135
- * name: 'mock-app',
136
- * env: 'test',
137
- * subdomainOffset: 2,
138
- * config: '<egg config>',
139
- * controller: '<egg controller>',
140
- * service: '<egg service>',
141
- * middlewares: '<egg middlewares>',
142
- * urllib: '<egg urllib>',
143
- * loggers: '<egg loggers>'
144
- * }
145
- * ```
146
- */
147
- inspect(): any;
148
- toJSON(): any;
149
- /**
150
- * http request helper base on {@link httpclient}, it will auto save httpclient log.
151
- * Keep the same api with `httpclient.request(url, args)`.
152
- *
153
- * See https://github.com/node-modules/urllib#api-doc for more details.
154
- *
155
- * @param {String} url request url address.
156
- * @param {Object} options
157
- * - method {String} - Request method, defaults to GET. Could be GET, POST, DELETE or PUT. Alias 'type'.
158
- * - data {Object} - Data to be sent. Will be stringify automatically.
159
- * - dataType {String} - String - Type of response data. Could be `text` or `json`.
160
- * If it's `text`, the callback data would be a String.
161
- * If it's `json`, the data of callback would be a parsed JSON Object.
162
- * Default callback data would be a Buffer.
163
- * - headers {Object} - Request headers.
164
- * - timeout {Number} - Request timeout in milliseconds. Defaults to exports.TIMEOUT.
165
- * Include remote server connecting timeout and response timeout.
166
- * When timeout happen, will return ConnectionTimeout or ResponseTimeout.
167
- * - auth {String} - `username:password` used in HTTP Basic Authorization.
168
- * - followRedirect {Boolean} - follow HTTP 3xx responses as redirects. defaults to false.
169
- * - gzip {Boolean} - let you get the res object when request connected, default false. alias customResponse
170
- * - nestedQuerystring {Boolean} - urllib default use querystring to stringify form data which don't
171
- * support nested object, will use qs instead of querystring to support nested object by set this option to true.
172
- * - more options see https://github.com/node-modules/urllib
173
- * @return {Object}
174
- * - status {Number} - HTTP response status
175
- * - headers {Object} - HTTP response headers
176
- * - res {Object} - HTTP response meta
177
- * - data {Object} - HTTP response body
178
- *
179
- * @example
180
- * ```js
181
- * const result = await app.curl('http://example.com/foo.json', {
182
- * method: 'GET',
183
- * dataType: 'json',
184
- * });
185
- * console.log(result.status, result.headers, result.data);
186
- * ```
187
- */
188
- curl<T = any>(url: HttpClientRequestURL, options?: HttpClientRequestOptions): Promise<HttpClientResponse<T>>;
189
- /**
190
- * Create a new HttpClient instance with custom options
191
- * @param {Object} [options] HttpClient init options
192
- */
193
- createHttpClient(options?: HttpClientOptions): HttpClient;
194
- /**
195
- * HttpClient instance
196
- * @see https://github.com/node-modules/urllib
197
- * @member {HttpClient}
198
- */
199
- get httpClient(): HttpClient;
200
- /**
201
- * @deprecated please use httpClient instead
202
- * @alias httpClient
203
- * @member {HttpClient}
204
- */
205
- get httpclient(): HttpClient;
206
- /**
207
- * All loggers contain logger, coreLogger and customLogger
208
- * @member {Object}
209
- * @since 1.0.0
210
- */
211
- get loggers(): EggLoggers;
212
- /**
213
- * Get logger by name, it's equal to app.loggers['name'],
214
- * but you can extend it with your own logical.
215
- * @param {String} name - logger name
216
- * @return {Logger} logger
217
- */
218
- getLogger(name: string): EggLogger;
219
- /**
220
- * application logger, log file is `$HOME/logs/{appname}/{appname}-web`
221
- * @member {Logger}
222
- * @since 1.0.0
223
- */
224
- get logger(): EggLogger;
225
- /**
226
- * core logger for framework and plugins, log file is `$HOME/logs/{appname}/egg-web`
227
- * @member {Logger}
228
- * @since 1.0.0
229
- */
230
- get coreLogger(): EggLogger;
231
- _unhandledRejectionHandler(err: any): void;
232
- /**
233
- * dump out the config and meta object
234
- * @private
235
- */
236
- dumpConfigToObject(): {
237
- config: Record<string, any>;
238
- meta: Record<string, any>;
239
- };
240
- /**
241
- * save app.config to `run/${type}_config.json`
242
- * @private
243
- */
244
- dumpConfig(): void;
245
- dumpTiming(): void;
246
- get [EGG_PATH](): string;
247
- get config(): EggAppConfig$1;
248
- /**
249
- * app.env delegate app.config.env
250
- * @deprecated
251
- */
252
- get env(): string;
253
- set env(_: string);
254
- /**
255
- * app.proxy delegate app.config.proxy
256
- * @deprecated
257
- */
258
- get proxy(): boolean;
259
- set proxy(_: boolean);
260
- /**
261
- * Create an anonymous context, the context isn't request level, so the request is mocked.
262
- * then you can use context level API like `ctx.service`
263
- * @member {String} EggApplication#createAnonymousContext
264
- * @param {Request} [req] - if you want to mock request like querystring, you can pass an object to this function.
265
- * @return {Context} context
266
- */
267
- createAnonymousContext(req?: any): EggContext;
268
- /**
269
- * Run async function in the anonymous context scope
270
- * @see Context#runInAnonymousContextScope
271
- * @param {Function} scope - the first args is an anonymous ctx, scope should be async function
272
- * @param {Request} [req] - if you want to mock request like querystring, you can pass an object to this function.
273
- */
274
- runInAnonymousContextScope(scope: (ctx: Context) => Promise<void>, req?: unknown): Promise<void>;
275
- /**
276
- * Create egg context
277
- * @function EggApplication#createContext
278
- * @param {Req} req - node native Request object
279
- * @param {Res} res - node native Response object
280
- * @return {Context} context object
281
- */
282
- createContext(req: IncomingMessage, res: ServerResponse): Context;
283
- }
284
- //#endregion
285
- export { Context, EggApplicationCore, EggApplicationCoreOptions, EggContext, type ILifecycleBoot as IBoot, type ILifecycleBoot, MiddlewareFunc, type Next, Request, Response, Router };
1
+ import "../EggApplicationLoader-PnIvd5oV.js";
2
+ import "../AppWorkerLoader-CT875rYM.js";
3
+ import "../AgentWorkerLoader-DG_hAClt.js";
4
+ import "../index-CUPkUUOR.js";
5
+ import { Context, EggApplicationCore, EggApplicationCoreOptions, EggContext, ILifecycleBoot, MiddlewareFunc, Next, Request, Router } from "../base_hook_class-R8A8gm1s.js";
6
+ import { Response } from "../response-DlNYDj00.js";
7
+ import "../types.plugin-C3D5I7VD.js";
8
+ import "../IMessenger-C9g6ypSI.js";
9
+ import "../CookieLimitExceedError-CAW0HYJw.js";
10
+ import "../MessageUnhandledRejectionError-Lq5fWw24.js";
11
+ import "../index-CkgLZdB4.js";
12
+ export { Context, EggApplicationCore, EggApplicationCoreOptions, EggContext, ILifecycleBoot as IBoot, ILifecycleBoot, MiddlewareFunc, Next, Request, Response, Router };