-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove nestjs microservices package and use parseMessage from core pa…
…ckage
- Loading branch information
Showing
10 changed files
with
128 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
import { BaseRpcContext } from '@nestjs/microservices'; | ||
|
||
import type { Channel } from '@rabbitmq-ts/core'; | ||
|
||
type TRqmContextArgs = [Record<string, any>, Channel, string]; | ||
interface IRabbitMQContextProps { | ||
pattern: string; | ||
channel: Channel; | ||
message: Record<string, any>; | ||
} | ||
|
||
export class RmqContext { | ||
#context: IRabbitMQContextProps; | ||
|
||
export class RmqContext extends BaseRpcContext<TRqmContextArgs> { | ||
constructor(args: TRqmContextArgs) { | ||
super(args); | ||
constructor(context: IRabbitMQContextProps) { | ||
this.#context = context; | ||
} | ||
|
||
public getMessage<T extends Record<string, any> = Record<string, any>>(): T { | ||
return this.args[0] as T; | ||
return this.#context.message as T; | ||
} | ||
|
||
public getChannel(): Channel { | ||
return this.args[1]; | ||
return this.#context.channel; | ||
} | ||
|
||
public getPattern(): string { | ||
return this.args[2]; | ||
return this.#context.pattern; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
export { Ctx, Payload } from '@nestjs/microservices'; | ||
|
||
export { Subscribe } from './decorators'; | ||
|
||
export * from './Context'; | ||
export { Subscribe, Ctx, Payload } from './decorators'; | ||
export * from './RabbitMQConsumer'; |
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
Oops, something went wrong.