egg 4.1.0-beta.2 → 4.1.0-beta.21
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 +3 -7
- package/dist/agent.js +6 -10
- package/dist/app/extend/context.d.ts +166 -193
- package/dist/app/extend/context.js +259 -244
- package/dist/app/extend/helper.d.ts +31 -36
- package/dist/app/extend/helper.js +41 -45
- package/dist/app/extend/request.d.ts +127 -140
- package/dist/app/extend/request.js +258 -219
- package/dist/app/extend/response.d.ts +22 -32
- package/dist/app/extend/response.js +34 -36
- package/dist/app/middleware/body_parser.d.ts +2 -2
- package/dist/app/middleware/body_parser.js +3 -7
- package/dist/app/middleware/meta.d.ts +8 -9
- package/dist/app/middleware/meta.js +19 -13
- package/dist/app/middleware/notfound.d.ts +5 -9
- package/dist/app/middleware/notfound.js +28 -25
- package/dist/app/middleware/override_method.d.ts +2 -2
- package/dist/app/middleware/override_method.js +3 -7
- package/dist/app/middleware/site_file.d.ts +7 -11
- package/dist/app/middleware/site_file.js +52 -37
- package/dist/config/config.default.d.ts +2 -8
- package/dist/config/config.default.js +376 -256
- package/dist/config/config.local.d.ts +5 -7
- package/dist/config/config.local.js +9 -6
- package/dist/config/config.unittest.d.ts +5 -7
- package/dist/config/config.unittest.js +8 -9
- package/dist/config/favicon.png +0 -0
- package/dist/config/plugin.d.ts +120 -122
- package/dist/config/plugin.js +121 -53
- package/dist/index.d.ts +66 -19
- package/dist/index.js +68 -19
- package/dist/lib/agent.d.ts +13 -16
- package/dist/lib/agent.js +46 -54
- package/dist/lib/application.d.ts +46 -61
- package/dist/lib/application.js +249 -197
- package/dist/lib/core/base_context_class.d.ts +12 -17
- package/dist/lib/core/base_context_class.js +15 -17
- package/dist/lib/core/base_context_logger.d.ts +35 -39
- package/dist/lib/core/base_context_logger.js +60 -58
- package/dist/lib/core/base_hook_class.d.ts +10 -17
- package/dist/lib/core/base_hook_class.js +22 -26
- package/dist/lib/core/context_httpclient.d.ts +16 -20
- package/dist/lib/core/context_httpclient.js +26 -29
- package/dist/lib/core/httpclient.d.ts +12 -15
- package/dist/lib/core/httpclient.js +37 -34
- package/dist/lib/core/logger.d.ts +3 -7
- package/dist/lib/core/logger.js +36 -30
- package/dist/lib/core/messenger/IMessenger.d.ts +49 -53
- package/dist/lib/core/messenger/IMessenger.js +2 -1
- package/dist/lib/core/messenger/base.d.ts +7 -11
- package/dist/lib/core/messenger/base.js +28 -29
- package/dist/lib/core/messenger/index.d.ts +4 -8
- package/dist/lib/core/messenger/index.js +8 -11
- package/dist/lib/core/messenger/ipc.d.ts +55 -59
- package/dist/lib/core/messenger/ipc.js +149 -120
- package/dist/lib/core/messenger/local.d.ts +56 -61
- package/dist/lib/core/messenger/local.js +126 -124
- package/dist/lib/core/utils.d.ts +2 -5
- package/dist/lib/core/utils.js +66 -44
- package/dist/lib/egg.d.ts +271 -292
- package/dist/lib/egg.js +576 -506
- package/dist/lib/error/CookieLimitExceedError.d.ts +4 -7
- package/dist/lib/error/CookieLimitExceedError.js +12 -15
- package/dist/lib/error/MessageUnhandledRejectionError.d.ts +4 -7
- package/dist/lib/error/MessageUnhandledRejectionError.js +12 -15
- package/dist/lib/error/index.d.ts +2 -3
- package/dist/lib/error/index.js +3 -4
- package/dist/lib/loader/AgentWorkerLoader.d.ts +7 -12
- package/dist/lib/loader/AgentWorkerLoader.js +18 -22
- package/dist/lib/loader/AppWorkerLoader.d.ts +12 -17
- package/dist/lib/loader/AppWorkerLoader.js +37 -35
- package/dist/lib/loader/EggApplicationLoader.d.ts +3 -7
- package/dist/lib/loader/EggApplicationLoader.js +4 -7
- package/dist/lib/loader/index.d.ts +3 -4
- package/dist/lib/loader/index.js +4 -5
- package/dist/lib/start.d.ts +18 -22
- package/dist/lib/start.js +42 -32
- package/dist/lib/types.d.ts +252 -230
- package/dist/lib/types.js +31 -14
- package/dist/lib/types.plugin.d.ts +12 -0
- package/dist/lib/types.plugin.js +14 -0
- package/dist/lib/utils.d.ts +2 -5
- package/dist/lib/utils.js +12 -12
- package/dist/urllib.d.ts +1 -2
- package/dist/urllib.js +2 -3
- package/package.json +31 -31
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,74 +1,63 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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,216 @@ 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
|
-
|
|
82
|
-
interface EggAppConfig extends
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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[];
|
|
125
230
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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;
|
|
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
|
+
};
|
|
164
246
|
};
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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;
|
|
247
|
+
clusterClient: {
|
|
248
|
+
maxWaitTime: number;
|
|
249
|
+
responseTimeout: number;
|
|
221
250
|
};
|
|
222
|
-
|
|
223
|
-
clusterClient: {
|
|
224
|
-
maxWaitTime: number;
|
|
225
|
-
responseTimeout: number;
|
|
226
|
-
};
|
|
227
|
-
[prop: string]: any;
|
|
251
|
+
[prop: string]: any;
|
|
228
252
|
}
|
|
229
|
-
type RequestObjectBody = Record<string, any>;
|
|
253
|
+
export type RequestObjectBody = Record<string, any>;
|
|
230
254
|
/**
|
|
231
255
|
* plugin config item interface
|
|
232
256
|
*/
|
|
233
|
-
interface IEggPluginItem {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
257
|
+
export interface IEggPluginItem {
|
|
258
|
+
env?: EggEnvType[];
|
|
259
|
+
path?: string;
|
|
260
|
+
package?: string;
|
|
261
|
+
enable?: boolean;
|
|
238
262
|
}
|
|
239
|
-
type EggPluginItem = IEggPluginItem | boolean;
|
|
263
|
+
export type EggPluginItem = IEggPluginItem | boolean;
|
|
240
264
|
/**
|
|
241
265
|
* build-in plugin list
|
|
242
266
|
*/
|
|
243
|
-
interface EggPlugin {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
267
|
+
export 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;
|
|
257
281
|
}
|
|
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
|
|
2
|
-
import "
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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,12 @@
|
|
|
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';
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMucGx1Z2luLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2xpYi90eXBlcy5wbHVnaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsc0RBQXNEO0FBRXRELE9BQU8sMEJBQTBCLENBQUM7QUFDbEMsT0FBTyxtQkFBbUIsQ0FBQztBQUMzQixPQUFPLG9CQUFvQixDQUFDO0FBQzVCLE9BQU8seUJBQXlCLENBQUM7QUFDakMsT0FBTyx3QkFBd0IsQ0FBQztBQUNoQyxPQUFPLHNCQUFzQixDQUFDO0FBQzlCLE9BQU8sdUJBQXVCLENBQUM7QUFDL0IsT0FBTyx1QkFBdUIsQ0FBQztBQUMvQixPQUFPLHNCQUFzQixDQUFDO0FBQzlCLE9BQU8scUJBQXFCLENBQUM7QUFDN0IsT0FBTyxtQkFBbUIsQ0FBQztBQUMzQixPQUFPLHNCQUFzQixDQUFDIn0=
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare function
|
|
3
|
-
declare function getSourceFile(filename: string): string;
|
|
4
|
-
//#endregion
|
|
5
|
-
export { getSourceDirname, getSourceFile };
|
|
1
|
+
export declare function getSourceDirname(): string;
|
|
2
|
+
export declare function getSourceFile(filename: string): string;
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import { fileURLToPath } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
export function getSourceDirname() {
|
|
4
|
+
if (typeof __dirname !== 'undefined') {
|
|
5
|
+
return path.dirname(__dirname);
|
|
6
|
+
}
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
return path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
|
8
10
|
}
|
|
9
|
-
function getSourceFile(filename) {
|
|
10
|
-
|
|
11
|
+
export function getSourceFile(filename) {
|
|
12
|
+
return path.join(getSourceDirname(), filename);
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
export { getSourceDirname, getSourceFile };
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbGliL3V0aWxzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sSUFBSSxNQUFNLFdBQVcsQ0FBQztBQUM3QixPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sVUFBVSxDQUFDO0FBRXpDLE1BQU0sVUFBVSxnQkFBZ0I7SUFDOUIsSUFBSSxPQUFPLFNBQVMsS0FBSyxXQUFXLEVBQUUsQ0FBQztRQUNyQyxPQUFPLElBQUksQ0FBQyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUM7SUFDakMsQ0FBQztJQUNELDZEQUE2RDtJQUM3RCxhQUFhO0lBQ2IsT0FBTyxJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsYUFBYSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFDO0FBQ3BFLENBQUM7QUFFRCxNQUFNLFVBQVUsYUFBYSxDQUFDLFFBQWdCO0lBQzVDLE9BQU8sSUFBSSxDQUFDLElBQUksQ0FBQyxnQkFBZ0IsRUFBRSxFQUFFLFFBQVEsQ0FBQyxDQUFDO0FBQ2pELENBQUMifQ==
|
package/dist/urllib.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export {};
|
|
1
|
+
export * from 'urllib';
|
package/dist/urllib.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
|
|
3
|
-
export { };
|
|
1
|
+
export * from 'urllib';
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXJsbGliLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3VybGxpYi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLFFBQVEsQ0FBQyJ9
|