diff --git a/src/presentation/animals/routes.ts b/src/presentation/animals/routes.ts index 98c5c35..15e5e44 100644 --- a/src/presentation/animals/routes.ts +++ b/src/presentation/animals/routes.ts @@ -90,12 +90,6 @@ export class AnimalRoutes { animalController.delete ); - router.post( - '/:id/add-favorite', - authMiddleware.authenticateUser, - animalController.addToFavorites - ); - return router; } } diff --git a/src/presentation/auth/routes.ts b/src/presentation/auth/routes.ts index 403f30c..24a894b 100644 --- a/src/presentation/auth/routes.ts +++ b/src/presentation/auth/routes.ts @@ -18,7 +18,7 @@ export class AuthRoutes { envs.MAILER_SECRET_KEY ); - const producer = new ProducerService(envs.RABBITMQ_URL, 'email-service'); + const producer = new ProducerService(envs.RABBITMQ_URL); const authService = new AuthService( jwt, diff --git a/src/presentation/services/producer.service.ts b/src/presentation/services/producer.service.ts index 6f7f46c..7244e7a 100644 --- a/src/presentation/services/producer.service.ts +++ b/src/presentation/services/producer.service.ts @@ -3,23 +3,31 @@ import amqp, { ChannelWrapper } from 'amqp-connection-manager'; export class ProducerService { private channelWrapper: ChannelWrapper; + private EXCHANGE: string; - constructor( - private readonly rabbitmqUrl: string, - private readonly queue: string - ) { + constructor(private readonly rabbitmqUrl: string) { + this.EXCHANGE = 'email-request'; const connection = amqp.connect(this.rabbitmqUrl); this.channelWrapper = connection.createChannel({ setup: (channel: Channel) => { - return channel.assertQueue(queue, { durable: true }); + // return channel.assertQueue(queue, { durable: true }); + return channel.assertExchange(this.EXCHANGE, 'direct', { + durable: true, + }); }, }); } async addToEmailQueue(payload: any) { try { - await this.channelWrapper.sendToQueue( - this.queue, + // await this.channelWrapper.sendToQueue( + // queue, + // Buffer.from(JSON.stringify(payload)), + // { persistent: true } + // ); + await this.channelWrapper.publish( + this.EXCHANGE, + 'verify-email', Buffer.from(JSON.stringify(payload)), { persistent: true } );