egg 4.1.0-beta.34 → 4.1.0-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +7 -3
- package/dist/agent.js +10 -6
- package/dist/ajv.d.ts +1 -1
- package/dist/ajv.js +3 -2
- package/dist/aop.d.ts +1 -1
- package/dist/aop.js +3 -2
- package/dist/app/extend/context.d.ts +181 -178
- package/dist/app/extend/context.js +244 -259
- package/dist/app/extend/helper.d.ts +40 -35
- package/dist/app/extend/helper.js +45 -41
- package/dist/app/extend/request.d.ts +135 -131
- package/dist/app/extend/request.js +219 -258
- package/dist/app/extend/response.d.ts +28 -24
- package/dist/app/extend/response.js +36 -34
- package/dist/app/middleware/body_parser.d.ts +2 -2
- package/dist/app/middleware/body_parser.js +7 -3
- package/dist/app/middleware/meta.d.ts +8 -8
- package/dist/app/middleware/meta.js +15 -18
- package/dist/app/middleware/notfound.d.ts +8 -5
- package/dist/app/middleware/notfound.js +25 -28
- package/dist/app/middleware/override_method.d.ts +2 -2
- package/dist/app/middleware/override_method.js +7 -3
- package/dist/app/middleware/site_file.d.ts +11 -7
- package/dist/app/middleware/site_file.js +37 -52
- package/dist/config/config.default.d.ts +11 -6
- package/dist/config/config.default.js +258 -375
- package/dist/config/config.local.d.ts +6 -3
- package/dist/config/config.local.js +7 -8
- package/dist/config/config.unittest.d.ts +6 -3
- package/dist/config/config.unittest.js +10 -8
- package/dist/config/plugin.d.ts +6 -2
- package/dist/config/plugin.js +67 -131
- package/dist/dal.d.ts +1 -1
- package/dist/dal.js +3 -2
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +3 -2
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +3 -2
- package/dist/index.d.ts +24 -106
- package/dist/index.js +23 -89
- package/dist/lib/agent.d.ts +21 -15
- package/dist/lib/agent.js +53 -45
- package/dist/lib/application.d.ts +60 -54
- package/dist/lib/application.js +200 -250
- package/dist/lib/core/base_context_class.d.ts +23 -17
- package/dist/lib/core/base_context_class.js +17 -15
- package/dist/lib/core/base_context_logger.d.ts +39 -35
- package/dist/lib/core/base_context_logger.js +58 -60
- package/dist/lib/core/base_hook_class.d.ts +18 -11
- package/dist/lib/core/base_hook_class.js +26 -22
- package/dist/lib/core/context_httpclient.d.ts +21 -16
- package/dist/lib/core/context_httpclient.js +29 -26
- package/dist/lib/core/httpclient.d.ts +14 -12
- package/dist/lib/core/httpclient.js +34 -37
- package/dist/lib/core/logger.d.ts +7 -3
- package/dist/lib/core/logger.js +30 -36
- package/dist/lib/core/messenger/IMessenger.d.ts +53 -49
- package/dist/lib/core/messenger/IMessenger.js +1 -2
- package/dist/lib/core/messenger/base.d.ts +11 -7
- package/dist/lib/core/messenger/base.js +30 -29
- package/dist/lib/core/messenger/index.d.ts +10 -6
- package/dist/lib/core/messenger/index.js +11 -8
- package/dist/lib/core/messenger/ipc.d.ts +62 -57
- package/dist/lib/core/messenger/ipc.js +126 -138
- package/dist/lib/core/messenger/local.d.ts +63 -58
- package/dist/lib/core/messenger/local.js +126 -131
- package/dist/lib/core/utils.d.ts +5 -2
- package/dist/lib/core/utils.js +44 -66
- package/dist/lib/define.d.ts +72 -67
- package/dist/lib/define.js +54 -53
- package/dist/lib/egg.d.ts +283 -281
- package/dist/lib/egg.js +512 -573
- package/dist/lib/error/CookieLimitExceedError.d.ts +7 -4
- package/dist/lib/error/CookieLimitExceedError.js +15 -12
- package/dist/lib/error/MessageUnhandledRejectionError.d.ts +7 -4
- package/dist/lib/error/MessageUnhandledRejectionError.js +15 -12
- package/dist/lib/error/index.d.ts +3 -2
- package/dist/lib/error/index.js +4 -3
- package/dist/lib/loader/AgentWorkerLoader.d.ts +15 -10
- package/dist/lib/loader/AgentWorkerLoader.js +22 -18
- package/dist/lib/loader/AppWorkerLoader.d.ts +20 -15
- package/dist/lib/loader/AppWorkerLoader.js +35 -37
- package/dist/lib/loader/EggApplicationLoader.d.ts +7 -3
- package/dist/lib/loader/EggApplicationLoader.js +7 -4
- package/dist/lib/loader/index.d.ts +4 -3
- package/dist/lib/loader/index.js +5 -4
- package/dist/lib/start.d.ts +24 -20
- package/dist/lib/start.js +32 -42
- package/dist/lib/types.d.ts +288 -286
- package/dist/lib/types.js +2 -2
- package/dist/lib/types.plugin.d.ts +21 -21
- package/dist/lib/types.plugin.js +23 -24
- package/dist/orm.d.ts +1 -1
- package/dist/orm.js +3 -2
- package/dist/schedule.d.ts +2 -2
- package/dist/schedule.js +5 -5
- package/dist/transaction.d.ts +1 -1
- package/dist/transaction.js +3 -2
- package/dist/urllib.d.ts +1 -1
- package/dist/urllib.js +3 -2
- package/package.json +60 -64
|
@@ -1,60 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV9jb250ZXh0X2xvZ2dlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9saWIvY29yZS9iYXNlX2NvbnRleHRfbG9nZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE1BQU0sT0FBTyxpQkFBaUI7SUFDbkIsSUFBSSxDQUFhO0lBQ2pCLFNBQVMsQ0FBVTtJQUU1Qjs7Ozs7T0FLRztJQUNILFlBQVksR0FBZSxFQUFFLFFBQWlCO1FBQzVDOzs7V0FHRztRQUNILElBQUksQ0FBQyxJQUFJLEdBQUcsR0FBRyxDQUFDO1FBQ2hCLElBQUksQ0FBQyxTQUFTLEdBQUcsUUFBUSxDQUFDO0lBQzVCLENBQUM7SUFFUyxJQUFJLENBQUMsTUFBMkMsRUFBRSxJQUFXO1FBQ3JFLDZCQUE2QjtRQUM3QixJQUFJLElBQUksQ0FBQyxTQUFTLElBQUksT0FBTyxJQUFJLENBQUMsQ0FBQyxDQUFDLEtBQUssUUFBUSxFQUFFLENBQUM7WUFDbEQsSUFBSSxDQUFDLENBQUMsQ0FBQyxHQUFHLElBQUksSUFBSSxDQUFDLFNBQVMsS0FBSyxJQUFJLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQztRQUM3QyxDQUFDO1FBQ0QsNkRBQTZEO1FBQzdELGFBQWE7UUFDYixJQUFJLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLENBQUMsR0FBRyxJQUFJLENBQUMsQ0FBQztJQUN4QyxDQUFDO0lBRUQ7Ozs7T0FJRztJQUNILEtBQUssQ0FBQyxHQUFHLElBQVc7UUFDbEIsSUFBSSxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUUsSUFBSSxDQUFDLENBQUM7SUFDM0IsQ0FBQztJQUVEOzs7O09BSUc7SUFDSCxJQUFJLENBQUMsR0FBRyxJQUFXO1FBQ2pCLElBQUksQ0FBQyxJQUFJLENBQUMsTUFBTSxFQUFFLElBQUksQ0FBQyxDQUFDO0lBQzFCLENBQUM7SUFFRDs7OztPQUlHO0lBQ0gsSUFBSSxDQUFDLEdBQUcsSUFBVztRQUNqQixJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sRUFBRSxJQUFJLENBQUMsQ0FBQztJQUMxQixDQUFDO0lBRUQ7Ozs7T0FJRztJQUNILEtBQUssQ0FBQyxHQUFHLElBQVc7UUFDbEIsSUFBSSxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUUsSUFBSSxDQUFDLENBQUM7SUFDM0IsQ0FBQztDQUNGIn0=
|
|
1
|
+
//#region src/lib/core/base_context_logger.ts
|
|
2
|
+
var BaseContextLogger = class {
|
|
3
|
+
#ctx;
|
|
4
|
+
#pathName;
|
|
5
|
+
/**
|
|
6
|
+
* @class
|
|
7
|
+
* @param {Context} ctx - context instance
|
|
8
|
+
* @param {String} pathName - class path name
|
|
9
|
+
* @since 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
constructor(ctx, pathName) {
|
|
12
|
+
/**
|
|
13
|
+
* @member {Context} BaseContextLogger#ctx
|
|
14
|
+
* @since 1.2.0
|
|
15
|
+
*/
|
|
16
|
+
this.#ctx = ctx;
|
|
17
|
+
this.#pathName = pathName;
|
|
18
|
+
}
|
|
19
|
+
_log(method, args) {
|
|
20
|
+
if (this.#pathName && typeof args[0] === "string") args[0] = `[${this.#pathName}] ${args[0]}`;
|
|
21
|
+
this.#ctx.app.logger[method](...args);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @member {Function} BaseContextLogger#debug
|
|
25
|
+
* @param {...any} args - log msg
|
|
26
|
+
* @since 1.2.0
|
|
27
|
+
*/
|
|
28
|
+
debug(...args) {
|
|
29
|
+
this._log("debug", args);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @member {Function} BaseContextLogger#info
|
|
33
|
+
* @param {...any} args - log msg
|
|
34
|
+
* @since 1.2.0
|
|
35
|
+
*/
|
|
36
|
+
info(...args) {
|
|
37
|
+
this._log("info", args);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @member {Function} BaseContextLogger#warn
|
|
41
|
+
* @param {...any} args - log msg
|
|
42
|
+
* @since 1.2.0
|
|
43
|
+
*/
|
|
44
|
+
warn(...args) {
|
|
45
|
+
this._log("warn", args);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @member {Function} BaseContextLogger#error
|
|
49
|
+
* @param {...any} args - log msg
|
|
50
|
+
* @since 1.2.0
|
|
51
|
+
*/
|
|
52
|
+
error(...args) {
|
|
53
|
+
this._log("error", args);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
export { BaseContextLogger };
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { EggAppConfig as EggAppConfig$1 } from "../types.js";
|
|
2
|
+
import { Agent } from "../agent.js";
|
|
3
|
+
import { Application } from "../application.js";
|
|
4
|
+
import "../../index.js";
|
|
5
|
+
import { ILifecycleBoot } from "@eggjs/core";
|
|
6
|
+
import { EggLogger } from "egg-logger";
|
|
7
|
+
|
|
8
|
+
//#region src/lib/core/base_hook_class.d.ts
|
|
9
|
+
declare class BaseHookClass implements ILifecycleBoot {
|
|
10
|
+
#private;
|
|
11
|
+
fullPath?: string;
|
|
12
|
+
constructor(instance: Application | Agent);
|
|
13
|
+
get logger(): EggLogger;
|
|
14
|
+
get config(): EggAppConfig$1;
|
|
15
|
+
get app(): Application;
|
|
16
|
+
get agent(): Agent;
|
|
12
17
|
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { BaseHookClass };
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import assert from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import assert from "node:assert";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/core/base_hook_class.ts
|
|
4
|
+
var BaseHookClass = class {
|
|
5
|
+
#instance;
|
|
6
|
+
constructor(instance) {
|
|
7
|
+
this.#instance = instance;
|
|
8
|
+
}
|
|
9
|
+
get logger() {
|
|
10
|
+
return this.#instance.logger;
|
|
11
|
+
}
|
|
12
|
+
get config() {
|
|
13
|
+
return this.#instance.config;
|
|
14
|
+
}
|
|
15
|
+
get app() {
|
|
16
|
+
assert(this.#instance.type === "application", "agent boot should not use app instance");
|
|
17
|
+
return this.#instance;
|
|
18
|
+
}
|
|
19
|
+
get agent() {
|
|
20
|
+
assert(this.#instance.type === "agent", "app boot should not use agent instance");
|
|
21
|
+
return this.#instance;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { BaseHookClass };
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { HttpClientRequestOptions, HttpClientRequestURL, HttpClientResponse } from "./httpclient.js";
|
|
2
|
+
import Context from "../../app/extend/context.js";
|
|
3
|
+
import "../egg.js";
|
|
4
|
+
import { Application } from "../application.js";
|
|
5
|
+
|
|
6
|
+
//#region src/lib/core/context_httpclient.d.ts
|
|
7
|
+
declare class ContextHttpClient {
|
|
8
|
+
ctx: Context;
|
|
9
|
+
app: Application;
|
|
10
|
+
constructor(ctx: Context);
|
|
11
|
+
/**
|
|
12
|
+
* http request helper base on {@link HttpClient}, it will auto save httpclient log.
|
|
13
|
+
* Keep the same api with {@link Application#curl}.
|
|
14
|
+
*
|
|
15
|
+
* @param {String|Object} url - request url address.
|
|
16
|
+
* @param {Object} [options] - options for request.
|
|
17
|
+
*/
|
|
18
|
+
curl<T = any>(url: HttpClientRequestURL, options?: HttpClientRequestOptions): Promise<HttpClientResponse<T>>;
|
|
19
|
+
request<T = any>(url: HttpClientRequestURL, options?: HttpClientRequestOptions): Promise<HttpClientResponse<T>>;
|
|
17
20
|
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ContextHttpClient };
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
1
|
+
//#region src/lib/core/context_httpclient.ts
|
|
2
|
+
var ContextHttpClient = class {
|
|
3
|
+
ctx;
|
|
4
|
+
app;
|
|
5
|
+
constructor(ctx) {
|
|
6
|
+
this.ctx = ctx;
|
|
7
|
+
this.app = ctx.app;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* http request helper base on {@link HttpClient}, it will auto save httpclient log.
|
|
11
|
+
* Keep the same api with {@link Application#curl}.
|
|
12
|
+
*
|
|
13
|
+
* @param {String|Object} url - request url address.
|
|
14
|
+
* @param {Object} [options] - options for request.
|
|
15
|
+
*/
|
|
16
|
+
async curl(url, options) {
|
|
17
|
+
options = {
|
|
18
|
+
...options,
|
|
19
|
+
ctx: this.ctx
|
|
20
|
+
};
|
|
21
|
+
return await this.app.curl(url, options);
|
|
22
|
+
}
|
|
23
|
+
async request(url, options) {
|
|
24
|
+
return await this.curl(url, options);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { ContextHttpClient };
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { EggApplicationCore } from "../egg.js";
|
|
2
|
+
import { ClientOptions, ClientOptions as HttpClientOptions, HttpClient as HttpClient$1, HttpClientResponse, HttpClientResponse as HttpClientResponse$1, RequestOptions, RequestURL, RequestURL as HttpClientRequestURL } from "urllib";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/core/httpclient.d.ts
|
|
5
|
+
interface HttpClientRequestOptions extends RequestOptions {
|
|
6
|
+
ctx?: any;
|
|
7
|
+
tracer?: any;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
declare class HttpClient extends HttpClient$1 {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(app: EggApplicationCore, options?: ClientOptions);
|
|
12
|
+
request<T = any>(url: RequestURL, options?: HttpClientRequestOptions): Promise<HttpClientResponse$1<T>>;
|
|
13
|
+
curl<T = any>(url: RequestURL, options?: HttpClientRequestOptions): Promise<HttpClientResponse$1<T>>;
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
//#endregion
|
|
16
|
+
export { type HttpClient as EggContextHttpClient, type HttpClient as EggHttpClient, HttpClient, type HttpClientOptions, HttpClientRequestOptions, type HttpClientRequestURL, type HttpClientResponse };
|
|
@@ -1,39 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return await this.request(url, options);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
import { ms } from "humanize-ms";
|
|
2
|
+
import { HttpClient as HttpClient$1 } from "urllib";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/core/httpclient.ts
|
|
5
|
+
var HttpClient = class extends HttpClient$1 {
|
|
6
|
+
#app;
|
|
7
|
+
constructor(app, options = {}) {
|
|
8
|
+
normalizeConfig(app);
|
|
9
|
+
const config = app.config.httpclient;
|
|
10
|
+
const initOptions = {
|
|
11
|
+
...options,
|
|
12
|
+
defaultArgs: {
|
|
13
|
+
...config.request,
|
|
14
|
+
...options.defaultArgs
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
super(initOptions);
|
|
18
|
+
this.#app = app;
|
|
19
|
+
}
|
|
20
|
+
async request(url, options) {
|
|
21
|
+
options = options ?? {};
|
|
22
|
+
if (options.ctx?.tracer) options.tracer = options.ctx.tracer;
|
|
23
|
+
else options.tracer = options.tracer ?? this.#app.tracer;
|
|
24
|
+
return await super.request(url, options);
|
|
25
|
+
}
|
|
26
|
+
async curl(url, options) {
|
|
27
|
+
return await this.request(url, options);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
33
30
|
function normalizeConfig(app) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
config.request.timeout = ms(config.request.timeout);
|
|
37
|
-
}
|
|
31
|
+
const config = app.config.httpclient;
|
|
32
|
+
if (typeof config.request?.timeout === "string") config.request.timeout = ms(config.request.timeout);
|
|
38
33
|
}
|
|
39
|
-
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { HttpClient };
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { EggApplicationCore } from "../egg.js";
|
|
2
|
+
import { EggLoggers } from "egg-logger";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/core/logger.d.ts
|
|
5
|
+
declare function createLoggers(app: EggApplicationCore): EggLoggers;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { createLoggers };
|
package/dist/lib/core/logger.js
CHANGED
|
@@ -1,37 +1,31 @@
|
|
|
1
|
-
import { EggLoggers } from
|
|
2
|
-
import { setCustomLogger } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// reset global logger on beforeClose hook
|
|
29
|
-
app.lifecycle.registerBeforeClose(() => {
|
|
30
|
-
for (const loggerName of Object.keys(loggers)) {
|
|
31
|
-
setCustomLogger(loggerName, undefined);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
loggers.coreLogger.info('[egg:lib:core:logger] init all loggers with options: %j', loggerOptions);
|
|
35
|
-
return loggers;
|
|
1
|
+
import { EggLoggers } from "egg-logger";
|
|
2
|
+
import { setCustomLogger } from "onelogger";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/core/logger.ts
|
|
5
|
+
function createLoggers(app) {
|
|
6
|
+
const loggerOptions = {
|
|
7
|
+
...app.config.logger,
|
|
8
|
+
type: app.type,
|
|
9
|
+
localStorage: app.ctxStorage
|
|
10
|
+
};
|
|
11
|
+
if (app.config.env === "prod" && loggerOptions.level === "DEBUG" && !app.config.logger.allowDebugAtProd) loggerOptions.level = "INFO";
|
|
12
|
+
const loggers = new EggLoggers({
|
|
13
|
+
logger: loggerOptions,
|
|
14
|
+
customLogger: app.config.customLogger
|
|
15
|
+
});
|
|
16
|
+
app.ready(() => {
|
|
17
|
+
if (app.config.logger.disableConsoleAfterReady) {
|
|
18
|
+
loggers.disableConsole();
|
|
19
|
+
loggers.coreLogger.info("[egg:lib:core:logger] disable console log after app ready");
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
for (const loggerName of Object.keys(loggers)) setCustomLogger(loggerName, loggers[loggerName]);
|
|
23
|
+
app.lifecycle.registerBeforeClose(() => {
|
|
24
|
+
for (const loggerName of Object.keys(loggers)) setCustomLogger(loggerName, void 0);
|
|
25
|
+
});
|
|
26
|
+
loggers.coreLogger.info("[egg:lib:core:logger] init all loggers with options: %j", loggerOptions);
|
|
27
|
+
return loggers;
|
|
36
28
|
}
|
|
37
|
-
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { createLoggers };
|
|
@@ -1,50 +1,54 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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;
|
|
50
52
|
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { IMessenger };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiSU1lc3Nlbmdlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9saWIvY29yZS9tZXNzZW5nZXIvSU1lc3Nlbmdlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
|
|
1
|
+
export { };
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { EggApplicationCore } from "../../egg.js";
|
|
2
|
+
import { EventEmitter } from "node:events";
|
|
3
|
+
|
|
4
|
+
//#region src/lib/core/messenger/base.d.ts
|
|
5
|
+
declare class BaseMessenger extends EventEmitter {
|
|
6
|
+
protected readonly egg: EggApplicationCore;
|
|
7
|
+
constructor(egg: EggApplicationCore);
|
|
8
|
+
private onRejection;
|
|
9
|
+
emit(eventName: string | symbol, ...args: any[]): boolean;
|
|
8
10
|
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { BaseMessenger };
|