-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(microservices): add extras param to pattern decorators
Add optional "extras" parameter for MessagePattern and EventPattern decorators. Allow embedding extra params into each message handler method and improve an experience of creating custom microservice transports
- Loading branch information
1 parent
b01afec
commit 26e9ed6
Showing
11 changed files
with
96 additions
and
42 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
12 changes: 10 additions & 2 deletions
12
packages/microservices/test/decorators/event-pattern.decorator.spec.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 |
---|---|---|
@@ -1,15 +1,23 @@ | ||
import { expect } from 'chai'; | ||
import { PATTERN_METADATA } from '../../constants'; | ||
import { PATTERN_METADATA, PATTERN_EXTRAS_METADATA } from '../../constants'; | ||
import { EventPattern } from '../../decorators/event-pattern.decorator'; | ||
|
||
describe('@EventPattern', () => { | ||
const pattern = { role: 'test' }; | ||
const extras = { param: 'value' }; | ||
class TestComponent { | ||
@EventPattern(pattern) | ||
@EventPattern(pattern, undefined, extras) | ||
public static test() {} | ||
} | ||
it(`should enhance method with ${PATTERN_METADATA} metadata`, () => { | ||
const metadata = Reflect.getMetadata(PATTERN_METADATA, TestComponent.test); | ||
expect(metadata).to.be.eql(pattern); | ||
}); | ||
it(`should enhance method with ${PATTERN_EXTRAS_METADATA} metadata`, () => { | ||
const metadata = Reflect.getMetadata( | ||
PATTERN_EXTRAS_METADATA, | ||
TestComponent.test, | ||
); | ||
expect(metadata).to.be.deep.equal(extras); | ||
}); | ||
}); |
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