egg 4.0.0 → 4.0.2

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 (65) hide show
  1. package/dist/commonjs/app/extend/context.d.ts +14 -1
  2. package/dist/commonjs/app/extend/context.js +1 -2
  3. package/dist/commonjs/app/extend/request.d.ts +9 -1
  4. package/dist/commonjs/app/extend/request.js +1 -2
  5. package/dist/commonjs/app/extend/response.d.ts +6 -1
  6. package/dist/commonjs/app/extend/response.js +1 -2
  7. package/dist/commonjs/config/plugin.js +6 -7
  8. package/dist/commonjs/index.d.ts +1 -0
  9. package/dist/commonjs/index.js +2 -1
  10. package/dist/commonjs/lib/core/httpclient.d.ts +3 -3
  11. package/dist/commonjs/lib/core/httpclient.js +10 -5
  12. package/dist/commonjs/lib/core/singleton.d.ts +16 -10
  13. package/dist/commonjs/lib/core/singleton.js +8 -3
  14. package/dist/commonjs/lib/egg.d.ts +21 -2
  15. package/dist/commonjs/lib/egg.js +9 -3
  16. package/dist/commonjs/lib/types.d.ts +17 -73
  17. package/dist/commonjs/lib/types.js +7 -1
  18. package/dist/esm/app/extend/context.d.ts +14 -1
  19. package/dist/esm/app/extend/context.js +1 -2
  20. package/dist/esm/app/extend/request.d.ts +9 -1
  21. package/dist/esm/app/extend/request.js +1 -2
  22. package/dist/esm/app/extend/response.d.ts +6 -1
  23. package/dist/esm/app/extend/response.js +1 -2
  24. package/dist/esm/config/plugin.js +6 -7
  25. package/dist/esm/index.d.ts +1 -0
  26. package/dist/esm/index.js +2 -1
  27. package/dist/esm/lib/core/httpclient.d.ts +3 -3
  28. package/dist/esm/lib/core/httpclient.js +10 -5
  29. package/dist/esm/lib/core/singleton.d.ts +16 -10
  30. package/dist/esm/lib/core/singleton.js +8 -3
  31. package/dist/esm/lib/egg.d.ts +21 -2
  32. package/dist/esm/lib/egg.js +9 -3
  33. package/dist/esm/lib/types.d.ts +17 -73
  34. package/dist/esm/lib/types.js +7 -1
  35. package/dist/package.json +1 -1
  36. package/package.json +6 -6
  37. package/src/app/extend/context.ts +16 -2
  38. package/src/app/extend/request.ts +11 -2
  39. package/src/app/extend/response.ts +8 -2
  40. package/src/config/plugin.ts +5 -7
  41. package/src/index.ts +1 -0
  42. package/src/lib/core/httpclient.ts +11 -4
  43. package/src/lib/core/singleton.ts +17 -12
  44. package/src/lib/egg.ts +30 -5
  45. package/src/lib/types.ts +18 -104
  46. package/dist/commonjs/app/extend/context.types.d.ts +0 -18
  47. package/dist/commonjs/app/extend/context.types.js +0 -3
  48. package/dist/commonjs/app/extend/request.types.d.ts +0 -10
  49. package/dist/commonjs/app/extend/request.types.js +0 -3
  50. package/dist/commonjs/app/extend/response.types.d.ts +0 -7
  51. package/dist/commonjs/app/extend/response.types.js +0 -3
  52. package/dist/commonjs/lib/egg.types.d.ts +0 -13
  53. package/dist/commonjs/lib/egg.types.js +0 -3
  54. package/dist/esm/app/extend/context.types.d.ts +0 -18
  55. package/dist/esm/app/extend/context.types.js +0 -2
  56. package/dist/esm/app/extend/request.types.d.ts +0 -10
  57. package/dist/esm/app/extend/request.types.js +0 -2
  58. package/dist/esm/app/extend/response.types.d.ts +0 -7
  59. package/dist/esm/app/extend/response.types.js +0 -2
  60. package/dist/esm/lib/egg.types.d.ts +0 -13
  61. package/dist/esm/lib/egg.types.js +0 -2
  62. package/src/app/extend/context.types.ts +0 -24
  63. package/src/app/extend/request.types.ts +0 -10
  64. package/src/app/extend/response.types.ts +0 -7
  65. package/src/lib/egg.types.ts +0 -15
package/src/lib/types.ts CHANGED
@@ -19,12 +19,17 @@ import type { SiteFileMiddlewareOptions } from '../app/middleware/site_file.js';
19
19
  // import plugins types
20
20
  import '@eggjs/watcher';
21
21
  import '@eggjs/development';
22
+ import '@eggjs/jsonp';
23
+ import '@eggjs/i18n';
24
+ import '@eggjs/static';
25
+ import '@eggjs/security';
26
+ import '@eggjs/schedule';
27
+ import '@eggjs/session';
22
28
 
23
29
  export type {
24
30
  EggAppInfo,
25
31
  } from '@eggjs/core';
26
32
 
27
-
28
33
  type IgnoreItem = string | RegExp | ((ctx: Context) => boolean);
29
34
  type IgnoreOrMatch = IgnoreItem | IgnoreItem[];
30
35
 
@@ -63,6 +68,17 @@ export interface CustomLoaderConfig extends Omit<FileLoaderOptions, 'inject' | '
63
68
  loadunit?: boolean;
64
69
  }
65
70
 
71
+ export interface HttpClientConfig {
72
+ /** Request timeout */
73
+ timeout?: number;
74
+ /** Default request args for httpclient */
75
+ request?: HttpClientRequestOptions;
76
+ /**
77
+ * @deprecated keep compatible with egg 3.x, no more used
78
+ */
79
+ useHttpClientNext?: boolean;
80
+ }
81
+
66
82
  export interface EggAppConfig extends EggCoreAppConfig {
67
83
  workerStartTimeout: number;
68
84
  baseDir: string;
@@ -138,47 +154,7 @@ export interface EggAppConfig extends EggCoreAppConfig {
138
154
  };
139
155
 
140
156
  /** Configuration of httpclient in egg. */
141
- httpclient: {
142
- /** Request timeout */
143
- timeout?: number;
144
- /** Default request args for httpclient */
145
- request?: HttpClientRequestOptions;
146
- /**
147
- * @deprecated keep compatible with egg 3.x, no more used
148
- */
149
- useHttpClientNext?: boolean;
150
- };
151
-
152
- // development: {
153
- // /**
154
- // * dirs needed watch, when files under these change, application will reload, use relative path
155
- // */
156
- // watchDirs: string[];
157
- // /**
158
- // * dirs don't need watch, including subdirectories, use relative path
159
- // */
160
- // ignoreDirs: string[];
161
- // /**
162
- // * don't wait all plugins ready, default is true.
163
- // */
164
- // fastReady: boolean;
165
- // /**
166
- // * whether reload on debug, default is true.
167
- // */
168
- // reloadOnDebug: boolean;
169
- // /**
170
- // * whether override default watchDirs, default is false.
171
- // */
172
- // overrideDefault: boolean;
173
- // /**
174
- // * whether override default ignoreDirs, default is false.
175
- // */
176
- // overrideIgnore: boolean;
177
- // /**
178
- // * whether to reload, use https://github.com/sindresorhus/multimatch
179
- // */
180
- // reloadPattern: string[] | string;
181
- // };
157
+ httpclient: HttpClientConfig;
182
158
 
183
159
  /**
184
160
  * customLoader config
@@ -209,32 +185,6 @@ export interface EggAppConfig extends EggCoreAppConfig {
209
185
 
210
186
  hostHeaders: string;
211
187
 
212
- /**
213
- * I18n options
214
- */
215
- i18n: {
216
- /**
217
- * default value EN_US
218
- */
219
- defaultLocale: string;
220
- /**
221
- * i18n resource file dir, not recommend to change default value
222
- */
223
- dirs: string[];
224
- /**
225
- * custom the locale value field, default `query.locale`, you can modify this config, such as `query.lang`
226
- */
227
- queryField: string;
228
- /**
229
- * The locale value key in the cookie, default is locale.
230
- */
231
- cookieField: string;
232
- /**
233
- * Locale cookie expire time, default `1y`, If pass number value, the unit will be ms
234
- */
235
- cookieMaxAge: string | number;
236
- };
237
-
238
188
  /**
239
189
  * Detect request' ip from specified headers, not case-sensitive. Only worked when config.proxy set to true.
240
190
  */
@@ -249,21 +199,6 @@ export interface EggAppConfig extends EggCoreAppConfig {
249
199
  httpOnly?: boolean;
250
200
  };
251
201
 
252
- /**
253
- * jsonp options
254
- * @member Config#jsonp
255
- * @property {String} callback - jsonp callback method key, default to `_callback`
256
- * @property {Number} limit - callback method name's max length, default to `50`
257
- * @property {Boolean} csrf - enable csrf check or not. default to false
258
- * @property {String|RegExp|Array} whiteList - referrer white list
259
- */
260
- jsonp: {
261
- limit: number;
262
- callback: string;
263
- csrf: boolean;
264
- whiteList: string | RegExp | Array<string | RegExp>;
265
- };
266
-
267
202
  /**
268
203
  * The key that signing cookies. It can contain multiple keys separated by .
269
204
  */
@@ -281,27 +216,6 @@ export interface EggAppConfig extends EggCoreAppConfig {
281
216
 
282
217
  rundir: string;
283
218
 
284
- security: {
285
- domainWhiteList: string[];
286
- protocolWhiteList: string[];
287
- defaultMiddleware: string;
288
- csrf: any;
289
- ssrf: {
290
- ipBlackList: string[];
291
- ipExceptionList: string[];
292
- checkAddress?(ip: string): boolean;
293
- };
294
- xframe: {
295
- enable: boolean;
296
- value: 'SAMEORIGIN' | 'DENY' | 'ALLOW-FROM';
297
- };
298
- hsts: any;
299
- methodnoallow: { enable: boolean };
300
- noopen: { enable: boolean; }
301
- xssProtection: any;
302
- csp: any;
303
- };
304
-
305
219
  siteFile: SiteFileMiddlewareOptions;
306
220
  meta: MetaMiddlewareOptions;
307
221
  notfound: NotFoundMiddlewareOptions;
@@ -1,18 +0,0 @@
1
- import type { Router } from '@eggjs/core';
2
- import type { EggLogger } from 'egg-logger';
3
- import type { HttpClientRequestURL, HttpClientRequestOptions, HttpClient } from '../../lib/core/httpclient.js';
4
- import type Helper from './helper.js';
5
- declare module '@eggjs/core' {
6
- interface Context {
7
- curl(url: HttpClientRequestURL, options?: HttpClientRequestOptions): ReturnType<HttpClient['request']>;
8
- get router(): Router;
9
- set router(val: Router);
10
- get helper(): Helper;
11
- get httpclient(): HttpClient;
12
- get httpClient(): HttpClient;
13
- getLogger(name: string): EggLogger;
14
- get logger(): EggLogger;
15
- get coreLogger(): EggLogger;
16
- get locals(): Record<string, any>;
17
- }
18
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udGV4dC50eXBlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9hcHAvZXh0ZW5kL2NvbnRleHQudHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
@@ -1,10 +0,0 @@
1
- declare module '@eggjs/core' {
2
- interface Request {
3
- body: any;
4
- get acceptJSON(): boolean;
5
- get query(): Record<string, string>;
6
- set query(obj: Record<string, string>);
7
- get queries(): Record<string, string[]>;
8
- }
9
- }
10
- export {};
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVxdWVzdC50eXBlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9hcHAvZXh0ZW5kL3JlcXVlc3QudHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
@@ -1,7 +0,0 @@
1
- declare module '@eggjs/core' {
2
- interface Response {
3
- get realStatus(): number;
4
- set realStatus(status: number);
5
- }
6
- }
7
- export {};
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVzcG9uc2UudHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBwL2V4dGVuZC9yZXNwb25zZS50eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
@@ -1,13 +0,0 @@
1
- import type { AsyncLocalStorage } from 'node:async_hooks';
2
- import type EggContext from '../app/extend/context.js';
3
- import type { EggLogger } from 'egg-logger';
4
- declare module '@eggjs/core' {
5
- interface EggCore {
6
- inspect(): any;
7
- get currentContext(): EggContext | undefined;
8
- ctxStorage: AsyncLocalStorage<EggContext>;
9
- get logger(): EggLogger;
10
- get coreLogger(): EggLogger;
11
- getLogger(name: string): EggLogger;
12
- }
13
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWdnLnR5cGVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2xpYi9lZ2cudHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
@@ -1,18 +0,0 @@
1
- import type { Router } from '@eggjs/core';
2
- import type { EggLogger } from 'egg-logger';
3
- import type { HttpClientRequestURL, HttpClientRequestOptions, HttpClient } from '../../lib/core/httpclient.js';
4
- import type Helper from './helper.js';
5
- declare module '@eggjs/core' {
6
- interface Context {
7
- curl(url: HttpClientRequestURL, options?: HttpClientRequestOptions): ReturnType<HttpClient['request']>;
8
- get router(): Router;
9
- set router(val: Router);
10
- get helper(): Helper;
11
- get httpclient(): HttpClient;
12
- get httpClient(): HttpClient;
13
- getLogger(name: string): EggLogger;
14
- get logger(): EggLogger;
15
- get coreLogger(): EggLogger;
16
- get locals(): Record<string, any>;
17
- }
18
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udGV4dC50eXBlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9hcHAvZXh0ZW5kL2NvbnRleHQudHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
@@ -1,10 +0,0 @@
1
- declare module '@eggjs/core' {
2
- interface Request {
3
- body: any;
4
- get acceptJSON(): boolean;
5
- get query(): Record<string, string>;
6
- set query(obj: Record<string, string>);
7
- get queries(): Record<string, string[]>;
8
- }
9
- }
10
- export {};
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVxdWVzdC50eXBlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9hcHAvZXh0ZW5kL3JlcXVlc3QudHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
@@ -1,7 +0,0 @@
1
- declare module '@eggjs/core' {
2
- interface Response {
3
- get realStatus(): number;
4
- set realStatus(status: number);
5
- }
6
- }
7
- export {};
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVzcG9uc2UudHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBwL2V4dGVuZC9yZXNwb25zZS50eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
@@ -1,13 +0,0 @@
1
- import type { AsyncLocalStorage } from 'node:async_hooks';
2
- import type EggContext from '../app/extend/context.js';
3
- import type { EggLogger } from 'egg-logger';
4
- declare module '@eggjs/core' {
5
- interface EggCore {
6
- inspect(): any;
7
- get currentContext(): EggContext | undefined;
8
- ctxStorage: AsyncLocalStorage<EggContext>;
9
- get logger(): EggLogger;
10
- get coreLogger(): EggLogger;
11
- getLogger(name: string): EggLogger;
12
- }
13
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWdnLnR5cGVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2xpYi9lZ2cudHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
@@ -1,24 +0,0 @@
1
- import type {
2
- Router,
3
- } from '@eggjs/core';
4
- import type { EggLogger } from 'egg-logger';
5
- import type {
6
- HttpClientRequestURL, HttpClientRequestOptions, HttpClient,
7
- } from '../../lib/core/httpclient.js';
8
- import type Helper from './helper.js';
9
-
10
- declare module '@eggjs/core' {
11
- // add Context overrides types
12
- interface Context {
13
- curl(url: HttpClientRequestURL, options?: HttpClientRequestOptions): ReturnType<HttpClient['request']>;
14
- get router(): Router;
15
- set router(val: Router);
16
- get helper(): Helper;
17
- get httpclient(): HttpClient;
18
- get httpClient(): HttpClient;
19
- getLogger(name: string): EggLogger;
20
- get logger(): EggLogger;
21
- get coreLogger(): EggLogger;
22
- get locals(): Record<string, any>;
23
- }
24
- }
@@ -1,10 +0,0 @@
1
- declare module '@eggjs/core' {
2
- // add Request overrides types
3
- interface Request {
4
- body: any;
5
- get acceptJSON(): boolean;
6
- get query(): Record<string, string>;
7
- set query(obj: Record<string, string>);
8
- get queries(): Record<string, string[]>;
9
- }
10
- }
@@ -1,7 +0,0 @@
1
- declare module '@eggjs/core' {
2
- // add Response overrides types
3
- interface Response {
4
- get realStatus(): number;
5
- set realStatus(status: number);
6
- }
7
- }
@@ -1,15 +0,0 @@
1
- import type { AsyncLocalStorage } from 'node:async_hooks';
2
- import type EggContext from '../app/extend/context.js';
3
- import type { EggLogger } from 'egg-logger';
4
-
5
- declare module '@eggjs/core' {
6
- // add EggApplicationCore overrides types
7
- interface EggCore {
8
- inspect(): any;
9
- get currentContext(): EggContext | undefined;
10
- ctxStorage: AsyncLocalStorage<EggContext>;
11
- get logger(): EggLogger;
12
- get coreLogger(): EggLogger;
13
- getLogger(name: string): EggLogger;
14
- }
15
- }