Skip to content

Commit 696e9b7

Browse files
fengmk2Copilot
andauthored
fix: override app.currentContext type define (#5578)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added an application-level getter to access the current request context outside typical handlers. * **Tests** * Removed TypeScript type-checking test suites for application and plugin APIs. * **Chores** * Updated dev dependency versions for Node types, Mocha, and TypeScript. * Removed an unused type-testing tool from the workspace and packages. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 4db8b91 commit 696e9b7

File tree

7 files changed

+278
-758
lines changed

7 files changed

+278
-758
lines changed

packages/egg/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@
166166
"runscript": "catalog:",
167167
"sdk-base": "catalog:",
168168
"spy": "catalog:",
169-
"tsd": "catalog:",
170169
"tsdown": "catalog:",
171170
"typescript": "catalog:"
172171
},

packages/egg/src/lib/egg.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ export { Context, Router };
7373
*/
7474
export class EggApplicationCore extends EggCore {
7575
declare ctxStorage: AsyncLocalStorage<Context>;
76+
77+
/**
78+
* Get the current request context from AsyncLocalStorage.
79+
* This provides access to the context object for the current request lifecycle.
80+
* @returns {Context | undefined} The current request context, or undefined if not in a request scope.
81+
*/
82+
get currentContext() {
83+
return this.ctxStorage.getStore();
84+
}
85+
7686
// export context base classes, let framework can impl sub class and over context extend easily.
7787
ContextCookies = ContextCookies;
7888
ContextLogger = ContextLogger;

packages/egg/test/index.test-d.ts

Lines changed: 0 additions & 245 deletions
This file was deleted.

plugins/mock/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@
125125
"@eggjs/tegg-plugin": "catalog:",
126126
"@types/methods": "catalog:",
127127
"egg-errors": "catalog:",
128-
"tsd": "catalog:",
129128
"tsdown": "catalog:",
130129
"typescript": "catalog:"
131130
},

plugins/mock/test/index.test-d.ts

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)