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