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.
- package/dist/AgentWorkerLoader-DG_hAClt.d.ts +17 -0
- package/dist/AgentWorkerLoader-D_hceBRW.js +24 -0
- package/dist/AppWorkerLoader-CAtxJvGl.js +37 -0
- package/dist/AppWorkerLoader-CT875rYM.d.ts +22 -0
- package/dist/CookieLimitExceedError-CAW0HYJw.d.ts +8 -0
- package/dist/CookieLimitExceedError-DLGakbeu.js +15 -0
- package/dist/EggApplicationLoader-CMe1VQt1.js +7 -0
- package/dist/EggApplicationLoader-PnIvd5oV.d.ts +8 -0
- package/dist/IMessenger-C9g6ypSI.d.ts +54 -0
- package/dist/MessageUnhandledRejectionError-Lq5fWw24.d.ts +8 -0
- package/dist/MessageUnhandledRejectionError-oD_E1Ewl.js +15 -0
- package/dist/agent-BfFWeJj4.js +55 -0
- package/dist/agent.d.ts +11 -1
- package/dist/agent.js +1 -1
- package/dist/app/extend/context.d.ts +11 -182
- package/dist/app/extend/context.js +1 -242
- package/dist/app/extend/helper.d.ts +11 -41
- package/dist/app/extend/helper.js +3 -45
- package/dist/app/extend/request.d.ts +11 -135
- package/dist/app/extend/request.js +2 -224
- package/dist/app/extend/response.d.ts +1 -28
- package/dist/app/extend/response.js +1 -34
- package/dist/app/middleware/meta.d.ts +11 -10
- package/dist/app/middleware/notfound.d.ts +11 -10
- package/dist/app/middleware/site_file.d.ts +11 -12
- package/dist/application-DVwFQSa9.js +208 -0
- package/dist/base-KLVtlzUD.d.ts +12 -0
- package/dist/base_context_class-Xc1OZql9.js +19 -0
- package/dist/base_context_logger-CZU59PGA.js +58 -0
- package/dist/base_hook_class-D0Gu2p8r.js +26 -0
- package/dist/base_hook_class-R8A8gm1s.d.ts +1109 -0
- package/dist/config/config.default.d.ts +11 -2
- package/dist/config/config.default.js +26 -2
- package/dist/context-D1Wg7CXs.js +244 -0
- package/dist/context_httpclient-BpRMdJhf.js +29 -0
- package/dist/egg-DVo5e_lr.js +800 -0
- package/dist/error-BYo_LRnd.js +1 -0
- package/dist/helper-B3PKMPXq.js +47 -0
- package/dist/httpclient-C1QPc_R7.js +36 -0
- package/dist/index-CUPkUUOR.d.ts +1 -0
- package/dist/index-CkgLZdB4.d.ts +1 -0
- package/dist/index.d.ts +12 -20
- package/dist/index.js +26 -19
- package/dist/lib/agent.d.ts +11 -21
- package/dist/lib/agent.js +20 -54
- package/dist/lib/application.d.ts +11 -59
- package/dist/lib/application.js +21 -207
- package/dist/lib/core/base_context_class.d.ts +11 -22
- package/dist/lib/core/base_context_class.js +2 -17
- package/dist/lib/core/base_context_logger.d.ts +11 -39
- package/dist/lib/core/base_context_logger.js +1 -56
- package/dist/lib/core/base_hook_class.d.ts +11 -17
- package/dist/lib/core/base_hook_class.js +1 -24
- package/dist/lib/core/context_httpclient.d.ts +11 -21
- package/dist/lib/core/context_httpclient.js +1 -27
- package/dist/lib/core/httpclient.d.ts +12 -17
- package/dist/lib/core/httpclient.js +1 -34
- package/dist/lib/core/logger.d.ts +11 -1
- package/dist/lib/core/logger.js +1 -29
- package/dist/lib/core/messenger/IMessenger.d.ts +1 -53
- package/dist/lib/core/messenger/base.d.ts +12 -11
- package/dist/lib/core/messenger/base.js +15 -27
- package/dist/lib/core/messenger/index.d.ts +12 -11
- package/dist/lib/core/messenger/index.js +15 -11
- package/dist/lib/core/messenger/ipc.d.ts +12 -4
- package/dist/lib/core/messenger/ipc.js +15 -128
- package/dist/lib/core/messenger/local.d.ts +12 -4
- package/dist/lib/core/messenger/local.js +15 -124
- package/dist/lib/core/utils.js +1 -46
- package/dist/lib/egg.d.ts +12 -285
- package/dist/lib/egg.js +15 -518
- package/dist/lib/error/CookieLimitExceedError.d.ts +1 -7
- package/dist/lib/error/CookieLimitExceedError.js +1 -13
- package/dist/lib/error/MessageUnhandledRejectionError.d.ts +1 -7
- package/dist/lib/error/MessageUnhandledRejectionError.js +1 -13
- package/dist/lib/error/index.d.ts +3 -2
- package/dist/lib/error/index.js +3 -2
- package/dist/lib/loader/AgentWorkerLoader.d.ts +2 -16
- package/dist/lib/loader/AgentWorkerLoader.js +2 -22
- package/dist/lib/loader/AppWorkerLoader.d.ts +2 -21
- package/dist/lib/loader/AppWorkerLoader.js +2 -35
- package/dist/lib/loader/EggApplicationLoader.d.ts +1 -7
- package/dist/lib/loader/EggApplicationLoader.js +1 -5
- package/dist/lib/loader/index.d.ts +4 -3
- package/dist/lib/loader/index.js +4 -3
- package/dist/lib/start.d.ts +11 -27
- package/dist/lib/start.js +25 -34
- package/dist/lib/types.d.ts +12 -283
- package/dist/lib/types.js +2 -32
- package/dist/lib/types.plugin.d.ts +1 -12
- package/dist/lib/types.plugin.js +1 -12
- package/dist/lib/utils.js +1 -12
- package/dist/loader-3myZ-rpm.js +1 -0
- package/dist/logger-C4tIcO3S.js +31 -0
- package/dist/request-Cy_1DlaX.js +225 -0
- package/dist/response-CDeQ9Sx2.js +36 -0
- package/dist/response-DlNYDj00.d.ts +29 -0
- package/dist/src-BuOjXSrB.js +3 -0
- package/dist/start-4E84z796.js +35 -0
- package/dist/types-dKSyDnVp.js +32 -0
- package/dist/types.plugin-B2v0K0I8.js +14 -0
- package/dist/types.plugin-C3D5I7VD.d.ts +12 -0
- package/dist/utils-B1Rjsoi9.js +48 -0
- package/dist/utils-BDoYg6z6.js +14 -0
- package/package.json +22 -22
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EggApplicationLoader } from "./EggApplicationLoader-PnIvd5oV.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
|
|
17
|
+
export { AgentWorkerLoader };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EggApplicationLoader } from "./EggApplicationLoader-CMe1VQt1.js";
|
|
2
|
+
|
|
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
|
+
export { AgentWorkerLoader };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EggApplicationLoader } from "./EggApplicationLoader-CMe1VQt1.js";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/loader/AppWorkerLoader.ts
|
|
4
|
+
/**
|
|
5
|
+
* App worker process Loader, will load plugins
|
|
6
|
+
* @see https://github.com/eggjs/egg-core/blob/master/src/loader/egg_loader.ts
|
|
7
|
+
*/
|
|
8
|
+
var AppWorkerLoader = class extends EggApplicationLoader {
|
|
9
|
+
/**
|
|
10
|
+
* loadPlugin first, then loadConfig
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
*/
|
|
13
|
+
async loadConfig() {
|
|
14
|
+
await this.loadPlugin();
|
|
15
|
+
await super.loadConfig();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Load all directories in convention
|
|
19
|
+
* @since 1.0.0
|
|
20
|
+
*/
|
|
21
|
+
async load() {
|
|
22
|
+
await this.loadApplicationExtend();
|
|
23
|
+
await this.loadRequestExtend();
|
|
24
|
+
await this.loadResponseExtend();
|
|
25
|
+
await this.loadContextExtend();
|
|
26
|
+
await this.loadHelperExtend();
|
|
27
|
+
await this.loadCustomLoader();
|
|
28
|
+
await this.loadCustomApp();
|
|
29
|
+
await this.loadService();
|
|
30
|
+
await this.loadMiddleware();
|
|
31
|
+
await this.loadController();
|
|
32
|
+
await this.loadRouter();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { AppWorkerLoader };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EggApplicationLoader } from "./EggApplicationLoader-PnIvd5oV.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
|
|
22
|
+
export { AppWorkerLoader };
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { CookieLimitExceedError };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/core/messenger/IMessenger.d.ts
|
|
4
|
+
interface IMessenger extends EventEmitter {
|
|
5
|
+
/**
|
|
6
|
+
* Send message to all agent and app
|
|
7
|
+
* @param {String} action - message key
|
|
8
|
+
* @param {Object} data - message value
|
|
9
|
+
* @return {Messenger} this
|
|
10
|
+
*/
|
|
11
|
+
broadcast(action: string, data?: unknown): IMessenger;
|
|
12
|
+
/**
|
|
13
|
+
* send message to the specified process
|
|
14
|
+
* @param {String} workerId - the workerId of the receiver
|
|
15
|
+
* @param {String} action - message key
|
|
16
|
+
* @param {Object} data - message value
|
|
17
|
+
* @return {Messenger} this
|
|
18
|
+
*/
|
|
19
|
+
sendTo(workerId: string, action: string, data?: unknown): IMessenger;
|
|
20
|
+
/**
|
|
21
|
+
* send message to one app worker by random
|
|
22
|
+
* - if it's running in agent, it will send to one of app workers
|
|
23
|
+
* - if it's running in app, it will send to agent
|
|
24
|
+
* @param {String} action - message key
|
|
25
|
+
* @param {Object} data - message value
|
|
26
|
+
* @return {Messenger} this
|
|
27
|
+
*/
|
|
28
|
+
sendRandom(action: string, data?: unknown): IMessenger;
|
|
29
|
+
/**
|
|
30
|
+
* send message to app
|
|
31
|
+
* @param {String} action - message key
|
|
32
|
+
* @param {Object} data - message value
|
|
33
|
+
* @return {Messenger} this
|
|
34
|
+
*/
|
|
35
|
+
sendToApp(action: string, data?: unknown): IMessenger;
|
|
36
|
+
/**
|
|
37
|
+
* send message to agent
|
|
38
|
+
* @param {String} action - message key
|
|
39
|
+
* @param {Object} data - message value
|
|
40
|
+
* @return {Messenger} this
|
|
41
|
+
*/
|
|
42
|
+
sendToAgent(action: string, data?: unknown): IMessenger;
|
|
43
|
+
/**
|
|
44
|
+
* @param {String} action - message key
|
|
45
|
+
* @param {Object} data - message value
|
|
46
|
+
* @param {String} to - let master know how to send message
|
|
47
|
+
* @return {Messenger} this
|
|
48
|
+
*/
|
|
49
|
+
send(action: string, data: unknown, to?: string): IMessenger;
|
|
50
|
+
close(): void;
|
|
51
|
+
onMessage(message: any): void;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { IMessenger };
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
8
|
+
export { MessageUnhandledRejectionError };
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { MessageUnhandledRejectionError };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { EggApplicationCore } from "./egg-DVo5e_lr.js";
|
|
2
|
+
import { AgentWorkerLoader } from "./AgentWorkerLoader-D_hceBRW.js";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/agent.ts
|
|
5
|
+
const EGG_LOADER = Symbol.for("egg#loader");
|
|
6
|
+
/**
|
|
7
|
+
* Singleton instance in Agent Worker, extend {@link EggApplicationCore}
|
|
8
|
+
* @augments EggApplicationCore
|
|
9
|
+
*/
|
|
10
|
+
var Agent = class extends EggApplicationCore {
|
|
11
|
+
#agentAliveHandler;
|
|
12
|
+
/**
|
|
13
|
+
* @class
|
|
14
|
+
* @param {Object} options - see {@link EggApplicationCore}
|
|
15
|
+
*/
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super({
|
|
18
|
+
...options,
|
|
19
|
+
type: "agent"
|
|
20
|
+
});
|
|
21
|
+
this.#agentAliveHandler = setInterval(() => {
|
|
22
|
+
this.coreLogger.info("[]");
|
|
23
|
+
}, 1440 * 60 * 1e3);
|
|
24
|
+
}
|
|
25
|
+
get [EGG_LOADER]() {
|
|
26
|
+
return AgentWorkerLoader;
|
|
27
|
+
}
|
|
28
|
+
_wrapMessenger() {
|
|
29
|
+
for (const methodName of [
|
|
30
|
+
"broadcast",
|
|
31
|
+
"sendTo",
|
|
32
|
+
"sendToApp",
|
|
33
|
+
"sendToAgent",
|
|
34
|
+
"sendRandom"
|
|
35
|
+
]) wrapMethod(methodName, this.messenger, this.coreLogger);
|
|
36
|
+
function wrapMethod(methodName, messenger, logger) {
|
|
37
|
+
const originMethod = messenger[methodName];
|
|
38
|
+
messenger[methodName] = function(...args) {
|
|
39
|
+
const stack = (/* @__PURE__ */ new Error()).stack.split("\n").slice(1).join("\n");
|
|
40
|
+
logger.warn("agent can't call %s before server started\n%s", methodName, stack);
|
|
41
|
+
originMethod.apply(this, args);
|
|
42
|
+
};
|
|
43
|
+
messenger.prependOnceListener("egg-ready", () => {
|
|
44
|
+
messenger[methodName] = originMethod;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async close() {
|
|
49
|
+
clearInterval(this.#agentAliveHandler);
|
|
50
|
+
await super.close();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { Agent };
|
package/dist/agent.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./EggApplicationLoader-PnIvd5oV.js";
|
|
2
|
+
import "./AppWorkerLoader-CT875rYM.js";
|
|
3
|
+
import "./AgentWorkerLoader-DG_hAClt.js";
|
|
4
|
+
import "./index-CUPkUUOR.js";
|
|
5
|
+
import { BaseHookClass } from "./base_hook_class-R8A8gm1s.js";
|
|
6
|
+
import "./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";
|
|
2
12
|
|
|
3
13
|
//#region src/agent.d.ts
|
|
4
14
|
declare class EggAgentHook extends BaseHookClass {
|
package/dist/agent.js
CHANGED
|
@@ -1,183 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
interface Cookies$1 extends Cookies {
|
|
13
|
-
request: any;
|
|
14
|
-
response: any;
|
|
15
|
-
}
|
|
16
|
-
declare class Context extends Context$1 {
|
|
17
|
-
app: Application;
|
|
18
|
-
request: Request$1;
|
|
19
|
-
response: Response$1;
|
|
20
|
-
service: BaseContextClass$1;
|
|
21
|
-
proxy: any;
|
|
22
|
-
/**
|
|
23
|
-
* Request start time
|
|
24
|
-
* @member {Number} Context#starttime
|
|
25
|
-
*/
|
|
26
|
-
starttime: number;
|
|
27
|
-
/**
|
|
28
|
-
* Request start timer using `performance.now()`
|
|
29
|
-
* @member {Number} Context#performanceStarttime
|
|
30
|
-
*/
|
|
31
|
-
performanceStarttime: number;
|
|
32
|
-
/**
|
|
33
|
-
* Get the current visitor's cookies.
|
|
34
|
-
*/
|
|
35
|
-
get cookies(): Cookies$1;
|
|
36
|
-
/**
|
|
37
|
-
* Get a wrapper httpclient instance contain ctx in the hold request process
|
|
38
|
-
*
|
|
39
|
-
* @return {HttpClient} the wrapper httpclient instance
|
|
40
|
-
*/
|
|
41
|
-
get httpclient(): HttpClient;
|
|
42
|
-
/**
|
|
43
|
-
* Alias to {@link Context#httpclient}
|
|
44
|
-
*/
|
|
45
|
-
get httpClient(): HttpClient;
|
|
46
|
-
/**
|
|
47
|
-
* Shortcut for httpclient.curl
|
|
48
|
-
*
|
|
49
|
-
* @function Context#curl
|
|
50
|
-
* @param {String|Object} url - request url address.
|
|
51
|
-
* @param {Object} [options] - options for request.
|
|
52
|
-
* @return {Object} see {@link ContextHttpClient#curl}
|
|
53
|
-
*/
|
|
54
|
-
curl(url: HttpClientRequestURL, options?: HttpClientRequestOptions): ReturnType<HttpClient['request']>;
|
|
55
|
-
/**
|
|
56
|
-
* Alias to {@link Application#router}
|
|
57
|
-
*
|
|
58
|
-
* @member {Router} Context#router
|
|
59
|
-
* @since 1.0.0
|
|
60
|
-
* @example
|
|
61
|
-
* ```js
|
|
62
|
-
* this.router.pathFor('post', { id: 12 });
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
get router(): Router;
|
|
66
|
-
/**
|
|
67
|
-
* Set router to Context, only use on EggRouter
|
|
68
|
-
* @param {Router} val router instance
|
|
69
|
-
*/
|
|
70
|
-
set router(val: Router);
|
|
71
|
-
/**
|
|
72
|
-
* Get helper instance from {@link Application#Helper}
|
|
73
|
-
*
|
|
74
|
-
* @member {Helper} Context#helper
|
|
75
|
-
* @since 1.0.0
|
|
76
|
-
*/
|
|
77
|
-
get helper(): Helper;
|
|
78
|
-
/**
|
|
79
|
-
* Wrap app.loggers with context information,
|
|
80
|
-
* if a custom logger is defined by naming aLogger, then you can `ctx.getLogger('aLogger')`
|
|
81
|
-
*
|
|
82
|
-
* @param {String} name - logger name
|
|
83
|
-
*/
|
|
84
|
-
getLogger(name: string): EggLogger;
|
|
85
|
-
/**
|
|
86
|
-
* Logger for Application
|
|
87
|
-
*
|
|
88
|
-
* @member {Logger} Context#logger
|
|
89
|
-
* @since 1.0.0
|
|
90
|
-
* @example
|
|
91
|
-
* ```js
|
|
92
|
-
* this.logger.info('some request data: %j', this.request.body);
|
|
93
|
-
* this.logger.warn('WARNING!!!!');
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
get logger(): EggLogger;
|
|
97
|
-
/**
|
|
98
|
-
* Logger for frameworks and plugins
|
|
99
|
-
*
|
|
100
|
-
* @member {Logger} Context#coreLogger
|
|
101
|
-
* @since 1.0.0
|
|
102
|
-
*/
|
|
103
|
-
get coreLogger(): EggLogger;
|
|
104
|
-
/**
|
|
105
|
-
* locals is an object for view, you can use `app.locals` and `ctx.locals` to set variables,
|
|
106
|
-
* which will be used as data when view is rendering.
|
|
107
|
-
* The difference between `app.locals` and `ctx.locals` is the context level, `app.locals` is global level, and `ctx.locals` is request level. when you get `ctx.locals`, it will merge `app.locals`.
|
|
108
|
-
*
|
|
109
|
-
* when you set locals, only object is available
|
|
110
|
-
*
|
|
111
|
-
* ```js
|
|
112
|
-
* this.locals = {
|
|
113
|
-
* a: 1
|
|
114
|
-
* };
|
|
115
|
-
* this.locals = {
|
|
116
|
-
* b: 1
|
|
117
|
-
* };
|
|
118
|
-
* this.locals.c = 1;
|
|
119
|
-
* console.log(this.locals);
|
|
120
|
-
* {
|
|
121
|
-
* a: 1,
|
|
122
|
-
* b: 1,
|
|
123
|
-
* c: 1,
|
|
124
|
-
* };
|
|
125
|
-
* ```
|
|
126
|
-
*
|
|
127
|
-
* `ctx.locals` has cache, it only merges `app.locals` once in one request.
|
|
128
|
-
*
|
|
129
|
-
* @member {Object} Context#locals
|
|
130
|
-
*/
|
|
131
|
-
get locals(): Record<string, any>;
|
|
132
|
-
set locals(val: Record<string, any>);
|
|
133
|
-
/**
|
|
134
|
-
* alias to {@link Context#locals}, compatible with koa that use this variable
|
|
135
|
-
* @member {Object} state
|
|
136
|
-
* @see Context#locals
|
|
137
|
-
*/
|
|
138
|
-
get state(): Record<string, any>;
|
|
139
|
-
set state(val: Record<string, any>);
|
|
140
|
-
/**
|
|
141
|
-
* Run async function in the background
|
|
142
|
-
* @param {Function} scope - the first args is ctx
|
|
143
|
-
* ```js
|
|
144
|
-
* this.body = 'hi';
|
|
145
|
-
*
|
|
146
|
-
* this.runInBackground(async ctx => {
|
|
147
|
-
* await ctx.mysql.query(sql);
|
|
148
|
-
* await ctx.curl(url);
|
|
149
|
-
* });
|
|
150
|
-
* ```
|
|
151
|
-
*/
|
|
152
|
-
runInBackground(scope: (ctx: Context) => Promise<void>, taskName?: string): void;
|
|
153
|
-
_runInBackground(scope: (ctx: Context) => Promise<void>, taskName: string): Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* @member {Boolean} Context#acceptJSON
|
|
156
|
-
* @see Request#acceptJSON
|
|
157
|
-
* @since 1.0.0
|
|
158
|
-
*/
|
|
159
|
-
get acceptJSON(): boolean;
|
|
160
|
-
get query(): Record<string, string>;
|
|
161
|
-
/**
|
|
162
|
-
* @member {Array} Context#queries
|
|
163
|
-
* @see Request#queries
|
|
164
|
-
* @since 1.0.0
|
|
165
|
-
*/
|
|
166
|
-
get queries(): Record<string, string[]>;
|
|
167
|
-
/**
|
|
168
|
-
* @member {string} Context#ip
|
|
169
|
-
* @see Request#ip
|
|
170
|
-
* @since 1.0.0
|
|
171
|
-
*/
|
|
172
|
-
get ip(): string;
|
|
173
|
-
set ip(val: string);
|
|
174
|
-
/**
|
|
175
|
-
* @member {Number} Context#realStatus
|
|
176
|
-
* @see Response#realStatus
|
|
177
|
-
* @since 1.0.0
|
|
178
|
-
*/
|
|
179
|
-
get realStatus(): number;
|
|
180
|
-
set realStatus(val: number);
|
|
181
|
-
}
|
|
182
|
-
//#endregion
|
|
1
|
+
import "../../EggApplicationLoader-PnIvd5oV.js";
|
|
2
|
+
import "../../AppWorkerLoader-CT875rYM.js";
|
|
3
|
+
import "../../AgentWorkerLoader-DG_hAClt.js";
|
|
4
|
+
import "../../index-CUPkUUOR.js";
|
|
5
|
+
import { Context } from "../../base_hook_class-R8A8gm1s.js";
|
|
6
|
+
import "../../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";
|
|
183
12
|
export { Context as default };
|