-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix aop in constructor inject type (#247)
<!-- Thank you for your pull request. Please review below requirements. Bug fixes and new features should include tests and possibly benchmarks. Contributors guide: https://github.com/eggjs/egg/blob/master/CONTRIBUTING.md 感谢您贡献代码。请确认下列 checklist 的完成情况。 Bug 修复和新功能必须包含测试,必要时请附上性能测试。 Contributors guide: https://github.com/eggjs/egg/blob/master/CONTRIBUTING.md --> ##### Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [ ] `npm test` passes - [ ] tests and/or benchmarks are included - [ ] documentation is changed or added - [ ] commit message follows commit guidelines ##### Affected core subsystem(s) <!-- Provide affected core subsystem(s). --> ##### Description of change <!-- Provide a description of the change below this comment. --> <!-- - any feature? - close https://github.com/eggjs/egg/ISSUE_URL --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced AOP functionality with new hooks and advice injection methods. - Introduced a new module for constructor injection in AOP, improving dependency management. - **Bug Fixes** - Improved sequence of operations in module loading to ensure proper graph building. - **Tests** - Added a new test suite for constructor injection, increasing test coverage for AOP functionality. - **Documentation** - New `package.json` file created for the "aop-module" to define module configuration. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
8 changed files
with
176 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
core/aop-runtime/test/fixtures/modules/constructor_inject_aop/Hello.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ContextProto, Inject, SingletonProto } from '@eggjs/core-decorator'; | ||
import { Pointcut } from '@eggjs/aop-decorator'; | ||
import { PointcutAdvice, pointcutAdviceParams } from '../hello_point_cut/HelloPointCut'; | ||
|
||
@SingletonProto() | ||
export class Foo { | ||
} | ||
|
||
@ContextProto() | ||
export class HelloConstructorInject { | ||
id = 233; | ||
|
||
constructor(@Inject() readonly foo: Foo) { | ||
} | ||
|
||
@Pointcut(PointcutAdvice, { adviceParams: pointcutAdviceParams }) | ||
async hello(name: string) { | ||
return `hello ${name}`; | ||
} | ||
|
||
@Pointcut(PointcutAdvice, { adviceParams: pointcutAdviceParams }) | ||
async helloWithException(name: string) { | ||
throw new Error(`ops, exception for ${name}`); | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
core/aop-runtime/test/fixtures/modules/constructor_inject_aop/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "aop-module", | ||
"eggModule": { | ||
"name": "aopModule" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters