egg 4.1.0-beta.17 → 4.1.0-beta.19

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.
@@ -56,16 +56,5 @@ declare class Application extends EggApplicationCore {
56
56
  */
57
57
  toAsyncFunction(fn: (...args: any[]) => any): (...args: any[]) => any;
58
58
  }
59
- declare module '@eggjs/core' {
60
- interface EggCore {
61
- onClientError(err: any, socket: Socket): void;
62
- onServer(server: http.Server): void;
63
- locals: Record<string, any>;
64
- runInBackground(scope: (ctx: Context) => Promise<void>, req?: unknown): void;
65
- toAsyncFunction(fn: (...args: any[]) => any): (...args: any[]) => any;
66
- dumpConfig(): void;
67
- get keys(): string[];
68
- }
69
- }
70
59
  //#endregion
71
60
  export { Application };
@@ -1,5 +1,5 @@
1
+ import { Application } from "../application.js";
1
2
  import Context$1 from "../../app/extend/context.js";
2
- import { EggApplicationCore } from "../egg.js";
3
3
  import { BaseContextLogger } from "./base_context_logger.js";
4
4
  import { BaseContextClass as BaseContextClass$1 } from "@eggjs/core";
5
5
 
@@ -15,7 +15,7 @@ declare class BaseContextClass extends BaseContextClass$1 {
15
15
  [key: string | symbol]: any;
16
16
  ctx: Context$1;
17
17
  pathName?: string;
18
- app: EggApplicationCore;
18
+ app: Application;
19
19
  service: BaseContextClass;
20
20
  get logger(): BaseContextLogger;
21
21
  }
@@ -1,12 +1,12 @@
1
+ import { Application } from "../application.js";
1
2
  import { HttpClientRequestOptions, HttpClientRequestURL } from "./httpclient.js";
2
3
  import Context from "../../app/extend/context.js";
3
- import { EggApplicationCore } from "../egg.js";
4
4
  import * as node_modules_urllib_dist_esm_Response_js0 from "node_modules/urllib/dist/esm/Response.js";
5
5
 
6
6
  //#region src/lib/core/context_httpclient.d.ts
7
7
  declare class ContextHttpClient {
8
8
  ctx: Context;
9
- app: EggApplicationCore;
9
+ app: Application;
10
10
  constructor(ctx: Context);
11
11
  /**
12
12
  * http request helper base on {@link HttpClient}, it will auto save httpclient log.
package/dist/lib/egg.d.ts CHANGED
@@ -34,6 +34,12 @@ type MiddlewareFunc<T extends Context = Context> = MiddlewareFunc$1<T>;
34
34
  declare class EggApplicationCore extends EggCore {
35
35
  #private;
36
36
  ctxStorage: AsyncLocalStorage<Context>;
37
+ /**
38
+ * Get the current request context from AsyncLocalStorage.
39
+ * This provides access to the context object for the current request lifecycle.
40
+ * @returns {Context | undefined} The current request context, or undefined if not in a request scope.
41
+ */
42
+ get currentContext(): Context | undefined;
37
43
  ContextCookies: typeof Cookies;
38
44
  ContextLogger: typeof EggContextLogger;
39
45
  ContextHttpClient: typeof ContextHttpClient;
@@ -275,24 +281,5 @@ declare class EggApplicationCore extends EggCore {
275
281
  */
276
282
  createContext(req: IncomingMessage, res: ServerResponse): Context;
277
283
  }
278
- declare module '@eggjs/core' {
279
- interface EggCore {
280
- inspect(): any;
281
- get currentContext(): EggContext | undefined;
282
- ctxStorage: AsyncLocalStorage<EggContext>;
283
- getLogger(name: string): EggLogger;
284
- get loggers(): EggLoggers;
285
- createHttpClient(options?: HttpClientOptions): HttpClient;
286
- HttpClient: typeof HttpClient;
287
- get httpClient(): HttpClient;
288
- curl<T = any>(url: HttpClientRequestURL, options?: HttpClientRequestOptions): Promise<HttpClientResponse<T>>;
289
- createAnonymousContext(req?: any): EggContext;
290
- runInAnonymousContextScope(scope: (ctx: Context) => Promise<void>, req?: unknown): Promise<void>;
291
- readonly messenger: IMessenger;
292
- Subscription: typeof BaseContextClass$1;
293
- BaseHookClass: typeof BaseHookClass;
294
- Boot: typeof BaseHookClass;
295
- }
296
- }
297
284
  //#endregion
298
285
  export { Context, EggApplicationCore, EggApplicationCoreOptions, EggContext, type ILifecycleBoot as IBoot, type ILifecycleBoot, MiddlewareFunc, type Next, Request, Response, Router };
package/dist/lib/egg.js CHANGED
@@ -31,6 +31,14 @@ const EGG_PATH = Symbol.for("egg#eggPath");
31
31
  * @augments EggCore
32
32
  */
33
33
  var EggApplicationCore = class extends EggCore {
34
+ /**
35
+ * Get the current request context from AsyncLocalStorage.
36
+ * This provides access to the context object for the current request lifecycle.
37
+ * @returns {Context | undefined} The current request context, or undefined if not in a request scope.
38
+ */
39
+ get currentContext() {
40
+ return this.ctxStorage.getStore();
41
+ }
34
42
  ContextCookies = Cookies;
35
43
  ContextLogger = EggContextLogger;
36
44
  ContextHttpClient = ContextHttpClient;
@@ -1,8 +1,8 @@
1
+ import { Application } from "./application.js";
1
2
  import Context$1 from "../app/extend/context.js";
2
3
  import { MetaMiddlewareOptions } from "../app/middleware/meta.js";
3
4
  import { NotFoundMiddlewareOptions } from "../app/middleware/notfound.js";
4
5
  import { SiteFileMiddlewareOptions } from "../app/middleware/site_file.js";
5
- import { EggApplicationCore } from "./egg.js";
6
6
  import { EggAppConfig as EggAppConfig$1, EggAppInfo, FileLoaderOptions } from "@eggjs/core";
7
7
  import { EggLoggerOptions, EggLoggersOptions } from "egg-logger";
8
8
  import { RequestOptions } from "urllib";
@@ -228,7 +228,7 @@ interface EggAppConfig extends EggAppConfig$1 {
228
228
  enable: boolean;
229
229
  allowedMethods: string[];
230
230
  };
231
- onClientError?(err: Error, socket: Socket, app: EggApplicationCore): ClientErrorResponse | Promise<ClientErrorResponse>;
231
+ onClientError?(err: Error, socket: Socket, app: Application): ClientErrorResponse | Promise<ClientErrorResponse>;
232
232
  /**
233
233
  * server timeout in milliseconds, default to 0 (no timeout).
234
234
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egg",
3
- "version": "4.1.0-beta.17",
3
+ "version": "4.1.0-beta.19",
4
4
  "engines": {
5
5
  "node": ">=22.18.0"
6
6
  },
@@ -86,23 +86,23 @@
86
86
  "type-fest": "^5.0.1",
87
87
  "urllib": "^4.8.2",
88
88
  "utility": "^2.5.0",
89
- "@eggjs/cluster": "4.0.0-beta.17",
90
- "@eggjs/cookies": "4.0.0-beta.17",
91
- "@eggjs/core": "7.0.0-beta.17",
92
- "@eggjs/extend2": "5.0.0-beta.17",
93
- "@eggjs/development": "5.0.0-beta.17",
94
- "@eggjs/jsonp": "4.0.0-beta.17",
95
- "@eggjs/logrotator": "5.0.0-beta.17",
96
- "@eggjs/multipart": "5.0.0-beta.17",
97
- "@eggjs/onerror": "4.0.0-beta.17",
98
- "@eggjs/i18n": "4.0.0-beta.17",
99
- "@eggjs/schedule": "6.0.0-beta.17",
100
- "@eggjs/security": "5.0.0-beta.17",
101
- "@eggjs/session": "5.0.0-beta.17",
102
- "@eggjs/utils": "5.0.0-beta.17",
103
- "@eggjs/static": "4.0.0-beta.17",
104
- "@eggjs/view": "4.0.0-beta.17",
105
- "@eggjs/watcher": "5.0.0-beta.17"
89
+ "@eggjs/cookies": "4.0.0-beta.19",
90
+ "@eggjs/cluster": "4.0.0-beta.19",
91
+ "@eggjs/development": "5.0.0-beta.19",
92
+ "@eggjs/core": "7.0.0-beta.19",
93
+ "@eggjs/extend2": "5.0.0-beta.19",
94
+ "@eggjs/jsonp": "4.0.0-beta.19",
95
+ "@eggjs/logrotator": "5.0.0-beta.19",
96
+ "@eggjs/i18n": "4.0.0-beta.19",
97
+ "@eggjs/multipart": "5.0.0-beta.19",
98
+ "@eggjs/onerror": "4.0.0-beta.19",
99
+ "@eggjs/schedule": "6.0.0-beta.19",
100
+ "@eggjs/security": "5.0.0-beta.19",
101
+ "@eggjs/view": "4.0.0-beta.19",
102
+ "@eggjs/utils": "5.0.0-beta.19",
103
+ "@eggjs/static": "4.0.0-beta.19",
104
+ "@eggjs/watcher": "5.0.0-beta.19",
105
+ "@eggjs/session": "5.0.0-beta.19"
106
106
  },
107
107
  "devDependencies": {
108
108
  "@types/koa-bodyparser": "^4.3.12",
@@ -117,13 +117,12 @@
117
117
  "runscript": "^2.0.1",
118
118
  "sdk-base": "^5.0.1",
119
119
  "spy": "^1.0.0",
120
- "tsd": "^0.33.0",
121
120
  "tsdown": "^0.15.4",
122
- "typescript": "5.9.2",
123
- "@eggjs/mock": "7.0.0-beta.17",
124
- "@eggjs/koa": "3.1.0-beta.17",
125
- "@eggjs/tracer": "4.0.0-beta.17",
126
- "@eggjs/supertest": "9.0.0-beta.17"
121
+ "typescript": "^5.9.3",
122
+ "@eggjs/koa": "3.1.0-beta.19",
123
+ "@eggjs/supertest": "9.0.0-beta.19",
124
+ "@eggjs/mock": "7.0.0-beta.19",
125
+ "@eggjs/tracer": "4.0.0-beta.19"
127
126
  },
128
127
  "repository": {
129
128
  "type": "git",