-
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.
- Loading branch information
Showing
20 changed files
with
399 additions
and
34 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
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
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
63 changes: 63 additions & 0 deletions
63
core/controller-decorator/test/fixtures/AopMiddlewareController.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,63 @@ | ||
import { HTTPMethodEnum, IAdvice, ObjectInitType } from '@eggjs/tegg-types'; | ||
import { Middleware } from '../../src/decorator/Middleware'; | ||
import { Advice } from '@eggjs/aop-decorator'; | ||
import { HTTPController } from '../../src/decorator/http/HTTPController'; | ||
import { HTTPMethod } from '../../src/decorator/http/HTTPMethod'; | ||
|
||
@Advice({ | ||
initType: ObjectInitType.SINGLETON, | ||
}) | ||
export class FooAdvice implements IAdvice { | ||
async beforeCall(): Promise<void> { | ||
// ... | ||
} | ||
} | ||
|
||
@Advice({ | ||
initType: ObjectInitType.SINGLETON, | ||
}) | ||
export class BarAdvice implements IAdvice { | ||
async beforeCall(): Promise<void> { | ||
// ... | ||
} | ||
} | ||
|
||
@Advice({ | ||
initType: ObjectInitType.SINGLETON, | ||
}) | ||
export class FooMethodAdvice implements IAdvice { | ||
async beforeCall(): Promise<void> { | ||
// ... | ||
} | ||
} | ||
|
||
@Advice({ | ||
initType: ObjectInitType.SINGLETON, | ||
}) | ||
export class BarMethodAdvice implements IAdvice { | ||
async beforeCall(): Promise<void> { | ||
// ... | ||
} | ||
} | ||
|
||
@Middleware(FooAdvice, BarAdvice) | ||
@HTTPController() | ||
export class AopMiddlewareController { | ||
|
||
@Middleware(FooMethodAdvice, BarMethodAdvice) | ||
@HTTPMethod({ | ||
method: HTTPMethodEnum.GET, | ||
path: '/hello', | ||
}) | ||
async hello(): Promise<void> { | ||
return; | ||
} | ||
|
||
@HTTPMethod({ | ||
method: HTTPMethodEnum.GET, | ||
path: '/bye', | ||
}) | ||
async bye(): Promise<void> { | ||
return; | ||
} | ||
} |
Oops, something went wrong.