egg 4.1.0-beta.2 → 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 -206
- 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 -144
- package/dist/app/extend/request.js +2 -224
- package/dist/app/extend/response.d.ts +1 -34
- 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 +12 -4
- package/dist/config/config.default.js +34 -7
- package/dist/config/favicon.png +0 -0
- package/dist/config/plugin.d.ts +1 -1
- package/dist/config/plugin.js +1 -1
- 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 -18
- package/dist/index.js +27 -18
- package/dist/lib/agent.d.ts +11 -21
- package/dist/lib/agent.js +20 -54
- package/dist/lib/application.d.ts +11 -70
- 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 -20
- 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 +13 -4
- package/dist/lib/core/messenger/ipc.js +15 -120
- 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 -306
- package/dist/lib/egg.js +15 -510
- 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 -259
- package/dist/lib/types.js +3 -13
- package/dist/lib/types.plugin.d.ts +1 -0
- package/dist/lib/types.plugin.js +3 -0
- 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/urllib.d.ts +1 -2
- package/dist/utils-B1Rjsoi9.js +48 -0
- package/dist/utils-BDoYg6z6.js +14 -0
- package/package.json +30 -30
|
@@ -1,37 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "../../EggApplicationLoader-CMe1VQt1.js";
|
|
2
|
+
import { AppWorkerLoader } from "../../AppWorkerLoader-CAtxJvGl.js";
|
|
2
3
|
|
|
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
4
|
export { AppWorkerLoader };
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/lib/loader/EggApplicationLoader.d.ts
|
|
4
|
-
declare abstract class EggApplicationLoader extends EggLoader {
|
|
5
|
-
abstract load(): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
1
|
+
import { EggApplicationLoader } from "../../EggApplicationLoader-PnIvd5oV.js";
|
|
8
2
|
export { EggApplicationLoader };
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EggApplicationLoader } from "../../EggApplicationLoader-CMe1VQt1.js";
|
|
2
2
|
|
|
3
|
-
//#region src/lib/loader/EggApplicationLoader.ts
|
|
4
|
-
var EggApplicationLoader = class extends EggLoader {};
|
|
5
|
-
|
|
6
|
-
//#endregion
|
|
7
3
|
export { EggApplicationLoader };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { EggApplicationLoader } from "
|
|
2
|
-
import { AppWorkerLoader } from "
|
|
3
|
-
import { AgentWorkerLoader } from "
|
|
1
|
+
import { EggApplicationLoader } from "../../EggApplicationLoader-PnIvd5oV.js";
|
|
2
|
+
import { AppWorkerLoader } from "../../AppWorkerLoader-CT875rYM.js";
|
|
3
|
+
import { AgentWorkerLoader } from "../../AgentWorkerLoader-DG_hAClt.js";
|
|
4
|
+
import "../../index-CUPkUUOR.js";
|
|
4
5
|
export { AgentWorkerLoader, AppWorkerLoader, EggApplicationLoader };
|
package/dist/lib/loader/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { EggApplicationLoader } from "
|
|
2
|
-
import { AppWorkerLoader } from "
|
|
3
|
-
import { AgentWorkerLoader } from "
|
|
1
|
+
import { EggApplicationLoader } from "../../EggApplicationLoader-CMe1VQt1.js";
|
|
2
|
+
import { AppWorkerLoader } from "../../AppWorkerLoader-CAtxJvGl.js";
|
|
3
|
+
import { AgentWorkerLoader } from "../../AgentWorkerLoader-D_hceBRW.js";
|
|
4
|
+
import "../../loader-3myZ-rpm.js";
|
|
4
5
|
|
|
5
6
|
export { AgentWorkerLoader, AppWorkerLoader, EggApplicationLoader };
|
package/dist/lib/start.d.ts
CHANGED
|
@@ -1,28 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
ignoreWarning?: boolean;
|
|
13
|
-
mode?: 'single';
|
|
14
|
-
env?: string;
|
|
15
|
-
plugins?: EggPlugin;
|
|
16
|
-
}
|
|
17
|
-
interface SingleModeApplication extends Application {
|
|
18
|
-
agent: SingleModeAgent;
|
|
19
|
-
}
|
|
20
|
-
interface SingleModeAgent extends Agent {
|
|
21
|
-
app: SingleModeApplication;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Start egg with single process
|
|
25
|
-
*/
|
|
26
|
-
declare function startEgg(options?: StartEggOptions): Promise<SingleModeApplication>;
|
|
27
|
-
//#endregion
|
|
1
|
+
import "../EggApplicationLoader-PnIvd5oV.js";
|
|
2
|
+
import "../AppWorkerLoader-CT875rYM.js";
|
|
3
|
+
import "../AgentWorkerLoader-DG_hAClt.js";
|
|
4
|
+
import "../index-CUPkUUOR.js";
|
|
5
|
+
import { SingleModeAgent, SingleModeApplication, StartEggOptions, startEgg } 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";
|
|
28
12
|
export { SingleModeAgent, SingleModeApplication, StartEggOptions, startEgg };
|
package/dist/lib/start.js
CHANGED
|
@@ -1,36 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import "
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import "../base_hook_class-D0Gu2p8r.js";
|
|
2
|
+
import "../base_context_logger-CZU59PGA.js";
|
|
3
|
+
import "../base_context_class-Xc1OZql9.js";
|
|
4
|
+
import "../context-D1Wg7CXs.js";
|
|
5
|
+
import "../response-CDeQ9Sx2.js";
|
|
6
|
+
import "../request-Cy_1DlaX.js";
|
|
7
|
+
import "../CookieLimitExceedError-DLGakbeu.js";
|
|
8
|
+
import "../MessageUnhandledRejectionError-oD_E1Ewl.js";
|
|
9
|
+
import "../error-BYo_LRnd.js";
|
|
10
|
+
import "../egg-DVo5e_lr.js";
|
|
11
|
+
import "../context_httpclient-BpRMdJhf.js";
|
|
12
|
+
import "../httpclient-C1QPc_R7.js";
|
|
13
|
+
import "../logger-C4tIcO3S.js";
|
|
14
|
+
import "../utils-B1Rjsoi9.js";
|
|
15
|
+
import "../utils-BDoYg6z6.js";
|
|
16
|
+
import "../EggApplicationLoader-CMe1VQt1.js";
|
|
17
|
+
import "../AppWorkerLoader-CAtxJvGl.js";
|
|
18
|
+
import "../AgentWorkerLoader-D_hceBRW.js";
|
|
19
|
+
import "../loader-3myZ-rpm.js";
|
|
20
|
+
import "../agent-BfFWeJj4.js";
|
|
21
|
+
import "../helper-B3PKMPXq.js";
|
|
22
|
+
import "../application-DVwFQSa9.js";
|
|
23
|
+
import "../types.plugin-B2v0K0I8.js";
|
|
24
|
+
import "../types-dKSyDnVp.js";
|
|
25
|
+
import { startEgg } from "../start-4E84z796.js";
|
|
7
26
|
|
|
8
|
-
//#region src/lib/start.ts
|
|
9
|
-
/**
|
|
10
|
-
* Start egg with single process
|
|
11
|
-
*/
|
|
12
|
-
async function startEgg(options = {}) {
|
|
13
|
-
options.baseDir = options.baseDir ?? process.cwd();
|
|
14
|
-
options.mode = "single";
|
|
15
|
-
if (!options.framework) try {
|
|
16
|
-
options.framework = (await readJSON(path.join(options.baseDir, "package.json"))).egg.framework;
|
|
17
|
-
} catch {}
|
|
18
|
-
let AgentClass = Agent;
|
|
19
|
-
let ApplicationClass = Application;
|
|
20
|
-
if (options.framework) {
|
|
21
|
-
const framework = await importModule(options.framework, { paths: [options.baseDir] });
|
|
22
|
-
AgentClass = framework.Agent;
|
|
23
|
-
ApplicationClass = framework.Application;
|
|
24
|
-
}
|
|
25
|
-
const agent = new AgentClass({ ...options });
|
|
26
|
-
await agent.ready();
|
|
27
|
-
const application = new ApplicationClass({ ...options });
|
|
28
|
-
application.agent = agent;
|
|
29
|
-
agent.application = application;
|
|
30
|
-
await application.ready();
|
|
31
|
-
application.messenger.broadcast("egg-ready");
|
|
32
|
-
return application;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
27
|
export { startEgg };
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,259 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import "
|
|
11
|
-
import "
|
|
12
|
-
|
|
13
|
-
import "@eggjs/i18n";
|
|
14
|
-
import "@eggjs/static";
|
|
15
|
-
import "@eggjs/security";
|
|
16
|
-
import "@eggjs/schedule";
|
|
17
|
-
import "@eggjs/session";
|
|
18
|
-
import "@eggjs/onerror";
|
|
19
|
-
import "@eggjs/logrotator";
|
|
20
|
-
import "@eggjs/multipart";
|
|
21
|
-
import "@eggjs/view";
|
|
22
|
-
|
|
23
|
-
//#region src/lib/types.d.ts
|
|
24
|
-
type IgnoreItem = string | RegExp | ((ctx: Context$1) => boolean);
|
|
25
|
-
type IgnoreOrMatch = IgnoreItem | IgnoreItem[];
|
|
26
|
-
interface ClientErrorResponse {
|
|
27
|
-
body: string | Buffer;
|
|
28
|
-
status: number;
|
|
29
|
-
headers: {
|
|
30
|
-
[key: string]: string;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/** egg env type */
|
|
34
|
-
type EggEnvType = 'local' | 'unittest' | 'prod' | string;
|
|
35
|
-
/** logger config of egg */
|
|
36
|
-
interface EggLoggerConfig extends Omit<EggLoggersOptions, 'type'> {
|
|
37
|
-
/** custom config of coreLogger */
|
|
38
|
-
coreLogger?: Partial<EggLoggerOptions>;
|
|
39
|
-
/** allow debug log at prod, defaults to `false` */
|
|
40
|
-
allowDebugAtProd?: boolean;
|
|
41
|
-
/** disable logger console after app ready. defaults to `false` on local and unittest env, others is `true`. */
|
|
42
|
-
disableConsoleAfterReady?: boolean;
|
|
43
|
-
/** [deprecated] Defaults to `true`. */
|
|
44
|
-
enablePerformanceTimer?: boolean;
|
|
45
|
-
/** using the app logger instead of EggContextLogger, defaults to `false` */
|
|
46
|
-
enableFastContextLogger?: boolean;
|
|
47
|
-
}
|
|
48
|
-
/** Custom Loader Configuration */
|
|
49
|
-
interface CustomLoaderConfig extends Omit<FileLoaderOptions, 'inject' | 'target'> {
|
|
50
|
-
/**
|
|
51
|
-
* an object you wanner load to, value can only be 'ctx' or 'app'. default to app
|
|
52
|
-
*/
|
|
53
|
-
inject?: 'ctx' | 'app';
|
|
54
|
-
/**
|
|
55
|
-
* whether need to load files in plugins or framework, default to false
|
|
56
|
-
*/
|
|
57
|
-
loadunit?: boolean;
|
|
58
|
-
}
|
|
59
|
-
interface HttpClientConfig {
|
|
60
|
-
/** Request timeout */
|
|
61
|
-
timeout?: number;
|
|
62
|
-
/** Default request args for httpclient */
|
|
63
|
-
request?: RequestOptions;
|
|
64
|
-
/**
|
|
65
|
-
* @deprecated keep compatible with egg 3.x, no more used
|
|
66
|
-
*/
|
|
67
|
-
useHttpClientNext?: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Allow http2
|
|
70
|
-
*/
|
|
71
|
-
allowH2?: boolean;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Powerful Partial, Support adding ? modifier to a mapped property in deep level
|
|
75
|
-
* @example
|
|
76
|
-
* import { PowerPartial, EggAppConfig } from 'egg';
|
|
77
|
-
*
|
|
78
|
-
* // { view: { defaultEngines: string } } => { view?: { defaultEngines?: string } }
|
|
79
|
-
* type EggConfig = PowerPartial<EggAppConfig>
|
|
80
|
-
*/
|
|
81
|
-
type PowerPartial<T> = { [U in keyof T]?: T[U] extends object ? PowerPartial<T[U]> : T[U] };
|
|
82
|
-
interface EggAppConfig extends EggAppConfig$1 {
|
|
83
|
-
workerStartTimeout: number;
|
|
84
|
-
baseDir: string;
|
|
85
|
-
middleware: string[];
|
|
86
|
-
coreMiddleware: string[];
|
|
87
|
-
/**
|
|
88
|
-
* The option of `bodyParser` middleware
|
|
89
|
-
*
|
|
90
|
-
* @member Config#bodyParser
|
|
91
|
-
* @property {Boolean} enable - enable bodyParser or not, default to true
|
|
92
|
-
* @property {String | RegExp | Function | Array} ignore - won't parse request body when url path hit ignore pattern, can not set `ignore` when `match` presented
|
|
93
|
-
* @property {String | RegExp | Function | Array} match - will parse request body only when url path hit match pattern
|
|
94
|
-
* @property {String} encoding - body encoding config, default utf8
|
|
95
|
-
* @property {String} formLimit - form body size limit, default 1mb
|
|
96
|
-
* @property {String} jsonLimit - json body size limit, default 1mb
|
|
97
|
-
* @property {String} textLimit - json body size limit, default 1mb
|
|
98
|
-
* @property {Boolean} strict - json body strict mode, if set strict value true, then only receive object and array json body
|
|
99
|
-
* @property {Number} queryString.arrayLimit - from item array length limit, default 100
|
|
100
|
-
* @property {Number} queryString.depth - json value deep length, default 5
|
|
101
|
-
* @property {Number} queryString.parameterLimit - parameter number limit, default 1000
|
|
102
|
-
* @property {String[]} enableTypes - parser will only parse when request type hits enableTypes, default is ['json', 'form']
|
|
103
|
-
* @property {Object} extendTypes - support extend types
|
|
104
|
-
* @property {String} onProtoPoisoning - Defines what action must take when parsing a JSON object with `__proto__`. Possible values are `'error'`, `'remove'` and `'ignore'`. Default is `'error'`, it will return `400` response when `Prototype-Poisoning` happen.
|
|
105
|
-
*/
|
|
106
|
-
bodyParser: {
|
|
107
|
-
enable: boolean;
|
|
108
|
-
encoding: string;
|
|
109
|
-
formLimit: string;
|
|
110
|
-
jsonLimit: string;
|
|
111
|
-
textLimit: string;
|
|
112
|
-
strict: boolean;
|
|
113
|
-
queryString: {
|
|
114
|
-
arrayLimit: number;
|
|
115
|
-
depth: number;
|
|
116
|
-
parameterLimit: number;
|
|
117
|
-
};
|
|
118
|
-
ignore?: IgnoreOrMatch;
|
|
119
|
-
match?: IgnoreOrMatch;
|
|
120
|
-
enableTypes?: string[];
|
|
121
|
-
extendTypes?: {
|
|
122
|
-
json: string[];
|
|
123
|
-
form: string[];
|
|
124
|
-
text: string[];
|
|
125
|
-
};
|
|
126
|
-
/** Default is `'error'`, it will return `400` response when `Prototype-Poisoning` happen. */
|
|
127
|
-
onProtoPoisoning: 'error' | 'remove' | 'ignore';
|
|
128
|
-
onerror(err: any, ctx: Context$1): void;
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* logger options
|
|
132
|
-
* @member Config#logger
|
|
133
|
-
* @property {String} dir - directory of log files
|
|
134
|
-
* @property {String} encoding - log file encoding, defaults to utf8
|
|
135
|
-
* @property {String} level - default log level, could be: DEBUG, INFO, WARN, ERROR or NONE, defaults to INFO in production
|
|
136
|
-
* @property {String} consoleLevel - log level of stdout, defaults to `INFO` in local serverEnv, defaults to `WARN` in unittest, others is `NONE`
|
|
137
|
-
* @property {Boolean} disableConsoleAfterReady - disable logger console after app ready. defaults to `false` on local and unittest env, others is `true`.
|
|
138
|
-
* @property {Boolean} outputJSON - log as JSON or not, defaults to `false`
|
|
139
|
-
* @property {Boolean} buffer - if enabled, flush logs to disk at a certain frequency to improve performance, defaults to true
|
|
140
|
-
* @property {String} errorLogName - file name of errorLogger
|
|
141
|
-
* @property {String} coreLogName - file name of coreLogger
|
|
142
|
-
* @property {String} agentLogName - file name of agent worker log
|
|
143
|
-
* @property {Object} coreLogger - custom config of coreLogger
|
|
144
|
-
* @property {Boolean} allowDebugAtProd - allow debug log at prod, defaults to false
|
|
145
|
-
* @property {Boolean} enableFastContextLogger - using the app logger instead of EggContextLogger, defaults to false
|
|
146
|
-
*/
|
|
147
|
-
logger: EggLoggerConfig;
|
|
148
|
-
/** custom logger of egg */
|
|
149
|
-
customLogger: {
|
|
150
|
-
[key: string]: EggLoggerOptions;
|
|
151
|
-
};
|
|
152
|
-
/** Configuration of httpclient in egg. */
|
|
153
|
-
httpclient: HttpClientConfig;
|
|
154
|
-
/**
|
|
155
|
-
* customLoader config
|
|
156
|
-
*/
|
|
157
|
-
/**
|
|
158
|
-
* It will ignore special keys when dumpConfig
|
|
159
|
-
*/
|
|
160
|
-
dump: {
|
|
161
|
-
ignore: Set<string | RegExp>;
|
|
162
|
-
timing: {
|
|
163
|
-
slowBootActionMinDuration: number;
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
/**
|
|
167
|
-
* The environment of egg
|
|
168
|
-
*/
|
|
169
|
-
env: EggEnvType;
|
|
170
|
-
/**
|
|
171
|
-
* The current HOME directory
|
|
172
|
-
*/
|
|
173
|
-
HOME: string;
|
|
174
|
-
hostHeaders: string;
|
|
175
|
-
/**
|
|
176
|
-
* Detect request' ip from specified headers, not case-sensitive. Only worked when config.proxy set to true.
|
|
177
|
-
*/
|
|
178
|
-
ipHeaders: string;
|
|
179
|
-
protocolHeaders: string;
|
|
180
|
-
maxProxyCount: number;
|
|
181
|
-
maxIpsCount: number;
|
|
182
|
-
proxy: boolean;
|
|
183
|
-
cookies: {
|
|
184
|
-
sameSite?: string;
|
|
185
|
-
httpOnly?: boolean;
|
|
186
|
-
};
|
|
187
|
-
/**
|
|
188
|
-
* The key that signing cookies. It can contain multiple keys separated by .
|
|
189
|
-
*/
|
|
190
|
-
keys: string;
|
|
191
|
-
/**
|
|
192
|
-
* The name of the application
|
|
193
|
-
*/
|
|
194
|
-
name: string;
|
|
195
|
-
/**
|
|
196
|
-
* package.json
|
|
197
|
-
*/
|
|
198
|
-
pkg: Record<string, any>;
|
|
199
|
-
rundir: string;
|
|
200
|
-
siteFile: SiteFileMiddlewareOptions;
|
|
201
|
-
meta: MetaMiddlewareOptions;
|
|
202
|
-
notfound: NotFoundMiddlewareOptions;
|
|
203
|
-
overrideMethod: {
|
|
204
|
-
enable: boolean;
|
|
205
|
-
allowedMethods: string[];
|
|
206
|
-
};
|
|
207
|
-
onClientError?(err: Error, socket: Socket, app: EggApplicationCore): ClientErrorResponse | Promise<ClientErrorResponse>;
|
|
208
|
-
/**
|
|
209
|
-
* server timeout in milliseconds, default to 0 (no timeout).
|
|
210
|
-
*
|
|
211
|
-
* for special request, just use `ctx.req.setTimeout(ms)`
|
|
212
|
-
*
|
|
213
|
-
* @see https://nodejs.org/api/http.html#http_server_timeout
|
|
214
|
-
*/
|
|
215
|
-
serverTimeout: number | null;
|
|
216
|
-
cluster: {
|
|
217
|
-
listen: {
|
|
218
|
-
path: string;
|
|
219
|
-
port: number;
|
|
220
|
-
hostname: string;
|
|
221
|
-
};
|
|
222
|
-
};
|
|
223
|
-
clusterClient: {
|
|
224
|
-
maxWaitTime: number;
|
|
225
|
-
responseTimeout: number;
|
|
226
|
-
};
|
|
227
|
-
[prop: string]: any;
|
|
228
|
-
}
|
|
229
|
-
type RequestObjectBody = Record<string, any>;
|
|
230
|
-
/**
|
|
231
|
-
* plugin config item interface
|
|
232
|
-
*/
|
|
233
|
-
interface IEggPluginItem {
|
|
234
|
-
env?: EggEnvType[];
|
|
235
|
-
path?: string;
|
|
236
|
-
package?: string;
|
|
237
|
-
enable?: boolean;
|
|
238
|
-
}
|
|
239
|
-
type EggPluginItem = IEggPluginItem | boolean;
|
|
240
|
-
/**
|
|
241
|
-
* build-in plugin list
|
|
242
|
-
*/
|
|
243
|
-
interface EggPlugin {
|
|
244
|
-
[key: string]: EggPluginItem | undefined;
|
|
245
|
-
onerror?: EggPluginItem;
|
|
246
|
-
session?: EggPluginItem;
|
|
247
|
-
i18n?: EggPluginItem;
|
|
248
|
-
watcher?: EggPluginItem;
|
|
249
|
-
multipart?: EggPluginItem;
|
|
250
|
-
security?: EggPluginItem;
|
|
251
|
-
development?: EggPluginItem;
|
|
252
|
-
logrotator?: EggPluginItem;
|
|
253
|
-
schedule?: EggPluginItem;
|
|
254
|
-
static?: EggPluginItem;
|
|
255
|
-
jsonp?: EggPluginItem;
|
|
256
|
-
view?: EggPluginItem;
|
|
257
|
-
}
|
|
258
|
-
//#endregion
|
|
259
|
-
export { ClientErrorResponse, CustomLoaderConfig, EggAppConfig, type EggAppInfo, EggEnvType, EggLoggerConfig, EggPlugin, EggPluginItem, HttpClientConfig, IEggPluginItem, PowerPartial, RequestObjectBody };
|
|
1
|
+
import "../EggApplicationLoader-PnIvd5oV.js";
|
|
2
|
+
import "../AppWorkerLoader-CT875rYM.js";
|
|
3
|
+
import "../AgentWorkerLoader-DG_hAClt.js";
|
|
4
|
+
import "../index-CUPkUUOR.js";
|
|
5
|
+
import { ClientErrorResponse, CustomLoaderConfig, EggAppConfig, EggAppInfo, EggConfigFactory, EggEnvType, EggLoggerConfig, EggPlugin, EggPluginItem, HttpClientConfig, IEggPluginItem, PartialDeep, PartialEggConfig, PowerPartial, RequestObjectBody, defineConfig, defineConfigFactory } 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";
|
|
12
|
+
export { ClientErrorResponse, CustomLoaderConfig, EggAppConfig, EggAppInfo, EggConfigFactory, EggEnvType, EggLoggerConfig, EggPlugin, EggPluginItem, HttpClientConfig, IEggPluginItem, PartialDeep, PartialEggConfig, PowerPartial, RequestObjectBody, defineConfig, defineConfigFactory };
|
package/dist/lib/types.js
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import "
|
|
3
|
-
import "@eggjs/jsonp";
|
|
4
|
-
import "@eggjs/i18n";
|
|
5
|
-
import "@eggjs/static";
|
|
6
|
-
import "@eggjs/security";
|
|
7
|
-
import "@eggjs/schedule";
|
|
8
|
-
import "@eggjs/session";
|
|
9
|
-
import "@eggjs/onerror";
|
|
10
|
-
import "@eggjs/logrotator";
|
|
11
|
-
import "@eggjs/multipart";
|
|
12
|
-
import "@eggjs/view";
|
|
1
|
+
import "../types.plugin-B2v0K0I8.js";
|
|
2
|
+
import { defineConfig, defineConfigFactory } from "../types-dKSyDnVp.js";
|
|
13
3
|
|
|
14
|
-
export {
|
|
4
|
+
export { defineConfig, defineConfigFactory };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../types.plugin-C3D5I7VD.js";
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
1
|
+
import { getSourceDirname, getSourceFile } from "../utils-BDoYg6z6.js";
|
|
3
2
|
|
|
4
|
-
//#region src/lib/utils.ts
|
|
5
|
-
function getSourceDirname() {
|
|
6
|
-
if (typeof __dirname !== "undefined") return path.dirname(__dirname);
|
|
7
|
-
return path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
|
8
|
-
}
|
|
9
|
-
function getSourceFile(filename) {
|
|
10
|
-
return path.join(getSourceDirname(), filename);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
3
|
export { getSourceDirname, getSourceFile };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,31 @@
|
|
|
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;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { createLoggers };
|