Skip to content

Commit

Permalink
fix(@rhtml/amqp): changed name to queue instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Stradivario committed Jan 10, 2025
1 parent 96ea514 commit 8077bcd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 6 additions & 0 deletions packages/amqp/src/amqp.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ export interface ModuleConfig extends Options.Connect {
prefetchCount?: number;
}

export interface SubscribeDecoratorOptions {
queue: string;
consumeOptions?: Options.Consume;
assertOptions?: Options.AssertQueue;
}

export { Connection } from 'amqplib';
12 changes: 4 additions & 8 deletions packages/amqp/src/decorators/subscribe.decorator.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import { set } from '@rhtml/di';
import { Options } from 'amqplib';

import { SubscribeDecoratorOptions } from '../amqp.constants';
import { AmqpService } from '../amqp.service';

export const Subscribe =
<T>({
name,
queue,
consumeOptions = {},
assertOptions = {},
}: {
name: string;
consumeOptions?: Options.Consume;
assertOptions?: Options.AssertQueue;
}) =>
}: SubscribeDecoratorOptions) =>
(target: T, memberName: string) => {
const OnInit =
target['OnInit'] ||
Expand All @@ -23,7 +19,7 @@ export const Subscribe =
value: async function (...args: unknown[]) {
const amqpService = set(AmqpService);
await amqpService.subscribe(
name,
queue,
(msg, channel) => target[memberName].call(this, msg, channel),
{ assertOptions, consumeOptions }
);
Expand Down

0 comments on commit 8077bcd

Please sign in to comment.