egg 4.1.0-beta.3 → 4.1.0-beta.30

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 (88) hide show
  1. package/dist/agent.d.ts +3 -7
  2. package/dist/agent.js +6 -10
  3. package/dist/app/extend/context.d.ts +166 -193
  4. package/dist/app/extend/context.js +259 -244
  5. package/dist/app/extend/helper.d.ts +31 -36
  6. package/dist/app/extend/helper.js +41 -45
  7. package/dist/app/extend/request.d.ts +127 -140
  8. package/dist/app/extend/request.js +258 -219
  9. package/dist/app/extend/response.d.ts +22 -32
  10. package/dist/app/extend/response.js +34 -36
  11. package/dist/app/middleware/body_parser.d.ts +2 -2
  12. package/dist/app/middleware/body_parser.js +3 -7
  13. package/dist/app/middleware/meta.d.ts +9 -10
  14. package/dist/app/middleware/meta.js +19 -13
  15. package/dist/app/middleware/notfound.d.ts +6 -10
  16. package/dist/app/middleware/notfound.js +28 -25
  17. package/dist/app/middleware/override_method.d.ts +2 -2
  18. package/dist/app/middleware/override_method.js +3 -7
  19. package/dist/app/middleware/site_file.d.ts +8 -12
  20. package/dist/app/middleware/site_file.js +52 -37
  21. package/dist/config/config.default.d.ts +3 -8
  22. package/dist/config/config.default.js +377 -256
  23. package/dist/config/config.local.d.ts +3 -10
  24. package/dist/config/config.local.js +7 -6
  25. package/dist/config/config.unittest.d.ts +3 -9
  26. package/dist/config/config.unittest.js +7 -9
  27. package/dist/config/favicon.png +0 -0
  28. package/dist/config/plugin.d.ts +3 -124
  29. package/dist/config/plugin.js +162 -53
  30. package/dist/index.d.ts +84 -19
  31. package/dist/index.js +87 -19
  32. package/dist/lib/agent.d.ts +12 -17
  33. package/dist/lib/agent.js +45 -54
  34. package/dist/lib/application.d.ts +47 -62
  35. package/dist/lib/application.js +249 -197
  36. package/dist/lib/core/base_context_class.d.ts +13 -17
  37. package/dist/lib/core/base_context_class.js +15 -17
  38. package/dist/lib/core/base_context_logger.d.ts +35 -39
  39. package/dist/lib/core/base_context_logger.js +60 -58
  40. package/dist/lib/core/base_hook_class.d.ts +11 -17
  41. package/dist/lib/core/base_hook_class.js +22 -26
  42. package/dist/lib/core/context_httpclient.d.ts +16 -20
  43. package/dist/lib/core/context_httpclient.js +26 -29
  44. package/dist/lib/core/httpclient.d.ts +12 -15
  45. package/dist/lib/core/httpclient.js +37 -34
  46. package/dist/lib/core/logger.d.ts +3 -7
  47. package/dist/lib/core/logger.js +36 -30
  48. package/dist/lib/core/messenger/IMessenger.d.ts +49 -53
  49. package/dist/lib/core/messenger/IMessenger.js +2 -1
  50. package/dist/lib/core/messenger/base.d.ts +7 -11
  51. package/dist/lib/core/messenger/base.js +29 -29
  52. package/dist/lib/core/messenger/index.d.ts +4 -8
  53. package/dist/lib/core/messenger/index.js +8 -11
  54. package/dist/lib/core/messenger/ipc.d.ts +55 -59
  55. package/dist/lib/core/messenger/ipc.js +138 -120
  56. package/dist/lib/core/messenger/local.d.ts +56 -61
  57. package/dist/lib/core/messenger/local.js +131 -124
  58. package/dist/lib/core/utils.d.ts +2 -5
  59. package/dist/lib/core/utils.js +66 -44
  60. package/dist/lib/egg.d.ts +272 -294
  61. package/dist/lib/egg.js +574 -507
  62. package/dist/lib/error/CookieLimitExceedError.d.ts +4 -7
  63. package/dist/lib/error/CookieLimitExceedError.js +12 -15
  64. package/dist/lib/error/MessageUnhandledRejectionError.d.ts +4 -7
  65. package/dist/lib/error/MessageUnhandledRejectionError.js +12 -15
  66. package/dist/lib/error/index.d.ts +2 -3
  67. package/dist/lib/error/index.js +3 -4
  68. package/dist/lib/loader/AgentWorkerLoader.d.ts +7 -12
  69. package/dist/lib/loader/AgentWorkerLoader.js +18 -22
  70. package/dist/lib/loader/AppWorkerLoader.d.ts +12 -17
  71. package/dist/lib/loader/AppWorkerLoader.js +37 -35
  72. package/dist/lib/loader/EggApplicationLoader.d.ts +3 -7
  73. package/dist/lib/loader/EggApplicationLoader.js +4 -7
  74. package/dist/lib/loader/index.d.ts +3 -4
  75. package/dist/lib/loader/index.js +4 -5
  76. package/dist/lib/start.d.ts +18 -22
  77. package/dist/lib/start.js +42 -32
  78. package/dist/lib/types.d.ts +309 -230
  79. package/dist/lib/types.js +31 -14
  80. package/dist/lib/types.plugin.d.ts +21 -0
  81. package/dist/lib/types.plugin.js +24 -0
  82. package/dist/schedule.d.ts +2 -0
  83. package/dist/schedule.js +5 -0
  84. package/dist/urllib.d.ts +1 -1
  85. package/dist/urllib.js +2 -3
  86. package/package.json +42 -32
  87. package/dist/lib/utils.d.ts +0 -5
  88. package/dist/lib/utils.js +0 -14
@@ -1,74 +1,63 @@
1
- import Context$1 from "../app/extend/context.js";
2
- import { MetaMiddlewareOptions } from "../app/middleware/meta.js";
3
- import { NotFoundMiddlewareOptions } from "../app/middleware/notfound.js";
4
- import { SiteFileMiddlewareOptions } from "../app/middleware/site_file.js";
5
- import { EggApplicationCore } from "./egg.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 "@eggjs/watcher";
11
- import "@eggjs/development";
12
- import "@eggjs/jsonp";
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);
1
+ import type { Socket } from 'node:net';
2
+ import type { RequestOptions as HttpClientRequestOptions } from 'urllib';
3
+ import type { EggLoggerOptions, EggLoggersOptions } from 'egg-logger';
4
+ import type { FileLoaderOptions, EggAppConfig as EggCoreAppConfig, EggAppInfo } from '@eggjs/core';
5
+ import type { PartialDeep } from 'type-fest';
6
+ import type { Context } from './egg.ts';
7
+ import type { Application } from './application.ts';
8
+ import type { MetaMiddlewareOptions } from '../app/middleware/meta.ts';
9
+ import type { NotFoundMiddlewareOptions } from '../app/middleware/notfound.ts';
10
+ import type { SiteFileMiddlewareOptions } from '../app/middleware/site_file.ts';
11
+ import './types.plugin.ts';
12
+ export type { EggAppInfo, PartialDeep };
13
+ type IgnoreItem = string | RegExp | ((ctx: Context) => boolean);
25
14
  type IgnoreOrMatch = IgnoreItem | IgnoreItem[];
26
- interface ClientErrorResponse {
27
- body: string | Buffer;
28
- status: number;
29
- headers: {
30
- [key: string]: string;
31
- };
15
+ export interface ClientErrorResponse {
16
+ body: string | Buffer;
17
+ status: number;
18
+ headers: {
19
+ [key: string]: string;
20
+ };
32
21
  }
33
22
  /** egg env type */
34
- type EggEnvType = 'local' | 'unittest' | 'prod' | string;
23
+ export type EggEnvType = 'local' | 'unittest' | 'prod' | string;
35
24
  /** 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;
25
+ export 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;
47
36
  }
48
37
  /** 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;
38
+ export 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;
58
47
  }
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;
48
+ export interface HttpClientConfig {
49
+ /** Request timeout */
50
+ timeout?: number;
51
+ /** Default request args for httpclient */
52
+ request?: HttpClientRequestOptions;
53
+ /**
54
+ * @deprecated keep compatible with egg 3.x, no more used
55
+ */
56
+ useHttpClientNext?: boolean;
57
+ /**
58
+ * Allow http2
59
+ */
60
+ allowH2?: boolean;
72
61
  }
73
62
  /**
74
63
  * Powerful Partial, Support adding ? modifier to a mapped property in deep level
@@ -77,183 +66,273 @@ interface HttpClientConfig {
77
66
  *
78
67
  * // { view: { defaultEngines: string } } => { view?: { defaultEngines?: string } }
79
68
  * type EggConfig = PowerPartial<EggAppConfig>
69
+ *
70
+ * @deprecated use `PartialDeep` instead
71
+ */
72
+ export type PowerPartial<T> = PartialDeep<T>;
73
+ /**
74
+ * Partial EggAppConfig
75
+ */
76
+ export type PartialEggConfig = PartialDeep<EggAppConfig>;
77
+ /**
78
+ * Configuration factory function return type
79
+ */
80
+ export 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
+ export 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
+ * ```
80
103
  */
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;
104
+ export declare function defineConfigFactory(configFactory: EggConfigFactory): EggConfigFactory;
105
+ export interface EggAppConfig extends EggCoreAppConfig {
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): 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;
117
209
  };
118
- ignore?: IgnoreOrMatch;
119
- match?: IgnoreOrMatch;
120
- enableTypes?: string[];
121
- extendTypes?: {
122
- json: string[];
123
- form: string[];
124
- text: string[];
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
+ /**
225
+ * siteFile middleware options
226
+ */
227
+ siteFile: SiteFileMiddlewareOptions;
228
+ /**
229
+ * meta middleware options
230
+ */
231
+ meta: MetaMiddlewareOptions;
232
+ /**
233
+ * notfound middleware options
234
+ */
235
+ notfound: NotFoundMiddlewareOptions;
236
+ /**
237
+ * overrideMethod middleware options
238
+ */
239
+ overrideMethod: {
240
+ enable: boolean;
241
+ allowedMethods: string[];
125
242
  };
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;
243
+ /**
244
+ * onClientError handler
245
+ */
246
+ onClientError?(err: Error, socket: Socket, app: Application): ClientErrorResponse | Promise<ClientErrorResponse>;
247
+ /**
248
+ * server timeout in milliseconds, default to 0 (no timeout).
249
+ *
250
+ * for special request, just use `ctx.req.setTimeout(ms)`
251
+ *
252
+ * @see https://nodejs.org/api/http.html#http_server_timeout
253
+ */
254
+ serverTimeout: number | null;
255
+ cluster: {
256
+ listen: {
257
+ path: string;
258
+ port: number;
259
+ hostname: string;
260
+ };
164
261
  };
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;
262
+ clusterClient: {
263
+ maxWaitTime: number;
264
+ responseTimeout: number;
221
265
  };
222
- };
223
- clusterClient: {
224
- maxWaitTime: number;
225
- responseTimeout: number;
226
- };
227
- [prop: string]: any;
266
+ [prop: string]: any;
228
267
  }
229
- type RequestObjectBody = Record<string, any>;
268
+ export type RequestObjectBody = Record<string, any>;
230
269
  /**
231
270
  * plugin config item interface
232
271
  */
233
- interface IEggPluginItem {
234
- env?: EggEnvType[];
235
- path?: string;
236
- package?: string;
237
- enable?: boolean;
272
+ export interface IEggPluginItem {
273
+ env?: EggEnvType[];
274
+ path?: string;
275
+ package?: string;
276
+ enable?: boolean;
238
277
  }
239
- type EggPluginItem = IEggPluginItem | boolean;
278
+ export type EggPluginItem = IEggPluginItem | boolean;
240
279
  /**
241
280
  * build-in plugin list
242
281
  */
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;
282
+ export interface EggPlugin {
283
+ [key: string]: EggPluginItem | undefined;
284
+ onerror?: EggPluginItem;
285
+ session?: EggPluginItem;
286
+ i18n?: EggPluginItem;
287
+ watcher?: EggPluginItem;
288
+ multipart?: EggPluginItem;
289
+ security?: EggPluginItem;
290
+ development?: EggPluginItem;
291
+ logrotator?: EggPluginItem;
292
+ schedule?: EggPluginItem;
293
+ static?: EggPluginItem;
294
+ jsonp?: EggPluginItem;
295
+ view?: EggPluginItem;
296
+ }
297
+ /**
298
+ * The empty interface `IService` is a placeholder, for egg
299
+ * to auto injection service to ctx.service
300
+ *
301
+ * @example
302
+ *
303
+ * import { Service } from 'egg';
304
+ * class FooService extends Service {
305
+ * async bar() {}
306
+ * }
307
+ *
308
+ * declare module 'egg' {
309
+ * export interface IService {
310
+ * foo: FooService;
311
+ * }
312
+ * }
313
+ *
314
+ * Now I can get ctx.service.foo at controller and other service file.
315
+ */
316
+ export interface IService extends Record<string, any> {
317
+ }
318
+ /**
319
+ * The empty interface `IController` is a placeholder, for egg
320
+ * to auto injection controller to app.controller
321
+ *
322
+ * @example
323
+ *
324
+ * import { Controller } from 'egg';
325
+ * class HomeController extends Controller {
326
+ * async index() {}
327
+ * }
328
+ *
329
+ * declare module 'egg' {
330
+ * export interface IController {
331
+ * home: HomeController;
332
+ * }
333
+ * }
334
+ *
335
+ * Now I can get app.controller.home in the application.
336
+ */
337
+ export interface IController extends Record<string, any> {
257
338
  }
258
- //#endregion
259
- export { ClientErrorResponse, CustomLoaderConfig, EggAppConfig, type EggAppInfo, EggEnvType, EggLoggerConfig, EggPlugin, EggPluginItem, HttpClientConfig, IEggPluginItem, PowerPartial, RequestObjectBody };
package/dist/lib/types.js CHANGED
@@ -1,14 +1,31 @@
1
- import "@eggjs/watcher";
2
- import "@eggjs/development";
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";
13
-
14
- export { };
1
+ // import plugins types
2
+ import "./types.plugin.js";
3
+ /**
4
+ * Define configuration with type safety
5
+ * @example
6
+ * ```ts
7
+ * import { defineConfig } from 'egg';
8
+ *
9
+ * export default defineConfig({
10
+ * keys: 'my-keys',
11
+ * middleware: []
12
+ * });
13
+ * ```
14
+ */
15
+ export function defineConfig(config) {
16
+ return config;
17
+ }
18
+ /**
19
+ * Define configuration factory function with type safety
20
+ * @example
21
+ * ```ts
22
+ * export default defineConfigFactory((appInfo): PartialEggConfig => ({
23
+ * keys: appInfo.name + '_keys',
24
+ * middleware: []
25
+ * }));
26
+ * ```
27
+ */
28
+ export function defineConfigFactory(configFactory) {
29
+ return configFactory;
30
+ }
31
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL3R5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWFBLHVCQUF1QjtBQUN2QixPQUFPLG1CQUFtQixDQUFDO0FBK0UzQjs7Ozs7Ozs7Ozs7R0FXRztBQUNILE1BQU0sVUFBVSxZQUFZLENBQUMsTUFBd0I7SUFDbkQsT0FBTyxNQUFNLENBQUM7QUFDaEIsQ0FBQztBQUVEOzs7Ozs7Ozs7R0FTRztBQUNILE1BQU0sVUFBVSxtQkFBbUIsQ0FBQyxhQUErQjtJQUNqRSxPQUFPLGFBQWEsQ0FBQztBQUN2QixDQUFDIn0=
@@ -0,0 +1,21 @@
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';
13
+ import '@eggjs/ajv-plugin/types';
14
+ import '@eggjs/aop-plugin/types';
15
+ import '@eggjs/tegg-config/types';
16
+ import '@eggjs/controller-plugin/types';
17
+ import '@eggjs/dal-plugin/types';
18
+ import '@eggjs/eventbus-plugin/types';
19
+ import '@eggjs/orm-plugin/types';
20
+ import '@eggjs/schedule-plugin/types';
21
+ import '@eggjs/tegg-plugin/types';
@@ -0,0 +1,24 @@
1
+ // import plugin types only, avoid circular dependency
2
+ import '@eggjs/development/types';
3
+ import '@eggjs/i18n/types';
4
+ import '@eggjs/jsonp/types';
5
+ import '@eggjs/logrotator/types';
6
+ import '@eggjs/multipart/types';
7
+ import '@eggjs/onerror/types';
8
+ import '@eggjs/schedule/types';
9
+ import '@eggjs/security/types';
10
+ import '@eggjs/session/types';
11
+ import '@eggjs/static/types';
12
+ import '@eggjs/view/types';
13
+ import '@eggjs/watcher/types';
14
+ // enable tegg plugin types
15
+ import '@eggjs/ajv-plugin/types';
16
+ import '@eggjs/aop-plugin/types';
17
+ import '@eggjs/tegg-config/types';
18
+ import '@eggjs/controller-plugin/types';
19
+ import '@eggjs/dal-plugin/types';
20
+ import '@eggjs/eventbus-plugin/types';
21
+ import '@eggjs/orm-plugin/types';
22
+ import '@eggjs/schedule-plugin/types';
23
+ import '@eggjs/tegg-plugin/types';
24
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMucGx1Z2luLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xpYi90eXBlcy5wbHVnaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsc0RBQXNEO0FBRXRELE9BQU8sMEJBQTBCLENBQUM7QUFDbEMsT0FBTyxtQkFBbUIsQ0FBQztBQUMzQixPQUFPLG9CQUFvQixDQUFDO0FBQzVCLE9BQU8seUJBQXlCLENBQUM7QUFDakMsT0FBTyx3QkFBd0IsQ0FBQztBQUNoQyxPQUFPLHNCQUFzQixDQUFDO0FBQzlCLE9BQU8sdUJBQXVCLENBQUM7QUFDL0IsT0FBTyx1QkFBdUIsQ0FBQztBQUMvQixPQUFPLHNCQUFzQixDQUFDO0FBQzlCLE9BQU8scUJBQXFCLENBQUM7QUFDN0IsT0FBTyxtQkFBbUIsQ0FBQztBQUMzQixPQUFPLHNCQUFzQixDQUFDO0FBRTlCLDJCQUEyQjtBQUMzQixPQUFPLHlCQUF5QixDQUFDO0FBQ2pDLE9BQU8seUJBQXlCLENBQUM7QUFDakMsT0FBTywwQkFBMEIsQ0FBQztBQUNsQyxPQUFPLGdDQUFnQyxDQUFDO0FBQ3hDLE9BQU8seUJBQXlCLENBQUM7QUFDakMsT0FBTyw4QkFBOEIsQ0FBQztBQUN0QyxPQUFPLHlCQUF5QixDQUFDO0FBQ2pDLE9BQU8sOEJBQThCLENBQUM7QUFDdEMsT0FBTywwQkFBMEIsQ0FBQyJ9
@@ -0,0 +1,2 @@
1
+ export * from '@eggjs/schedule';
2
+ export * from '@eggjs/tegg/schedule';