-
Notifications
You must be signed in to change notification settings - Fork 579
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
1 parent
625629d
commit 871ea80
Showing
14 changed files
with
145 additions
and
13 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
12 changes: 12 additions & 0 deletions
12
packages/core/test/fixtures/base-app-aspect/src/aspect/c.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,12 @@ | ||
import { Aspect, IMethodAspect, JoinPoint, Provide } from '@midwayjs/decorator'; | ||
import { UserController } from '../home'; | ||
|
||
@Provide() | ||
@Aspect([UserController]) | ||
export class MyAspect3 implements IMethodAspect { | ||
afterThrow(point: JoinPoint, err): any { | ||
if (err.message === 'bbb') { | ||
throw new Error('ccc'); | ||
} | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
packages/web/test/fixtures/issue/base-app-aspect-throw/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,3 @@ | ||
{ | ||
"name": "ali-demo" | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/web/test/fixtures/issue/base-app-aspect-throw/src/aspect/testThrow.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,21 @@ | ||
import { Aspect, IMethodAspect, JoinPoint, Provide } from '@midwayjs/decorator'; | ||
import { UserController } from '../controller/User'; | ||
|
||
@Provide() | ||
@Aspect(UserController, 'api') | ||
export class ReportInfo implements IMethodAspect { | ||
async afterThrow(point: JoinPoint, err) { | ||
point.target.ctx.status = 200; | ||
point.target.ctx.body = 'hello'; | ||
} | ||
} | ||
|
||
@Provide() | ||
@Aspect(UserController, 'do*') | ||
export class ReportInfo1 implements IMethodAspect { | ||
async around(point: JoinPoint) { | ||
const result = await point.proceed(...point.args); // 执行原方法 | ||
return result + ' world'; | ||
} | ||
} | ||
|
13 changes: 13 additions & 0 deletions
13
packages/web/test/fixtures/issue/base-app-aspect-throw/src/config/config.default.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,13 @@ | ||
'use strict'; | ||
|
||
export const keys = 'key'; | ||
|
||
export const hello = { | ||
a: 1, | ||
b: 2, | ||
d: [1, 2, 3], | ||
}; | ||
|
||
export const plugins = { | ||
bucLogin: false, | ||
}; |
5 changes: 5 additions & 0 deletions
5
packages/web/test/fixtures/issue/base-app-aspect-throw/src/config/config.unittest.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,5 @@ | ||
|
||
exports.hello = { | ||
b: 4, | ||
c: 3, | ||
}; |
18 changes: 18 additions & 0 deletions
18
packages/web/test/fixtures/issue/base-app-aspect-throw/src/controller/User.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,18 @@ | ||
import { Controller, Get, Provide, Inject } from '@midwayjs/decorator'; | ||
|
||
@Provide() | ||
@Controller('/api/user') | ||
export class UserController { | ||
@Inject() | ||
ctx: any; | ||
|
||
@Get('/info') | ||
async api() { | ||
throw new Error('bbb'); | ||
} | ||
|
||
@Get('/ctx_bind') | ||
async doTestCtxBind() { | ||
return this.ctx.query.text; | ||
} | ||
} |
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