From e7d22f9e2772aef8b812490afffef1632c5e1763 Mon Sep 17 00:00:00 2001 From: thanhdanh27600 Date: Sun, 23 Jul 2023 13:48:20 +0700 Subject: [PATCH] fix export --- .gitignore | 1 + rabbitmq/consumer.ts | 50 ++++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 97c8f59a..cff239ea 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ next-env.d.ts *.env.production prisma/*.db* /logs +*.log diff --git a/rabbitmq/consumer.ts b/rabbitmq/consumer.ts index c5a4bee0..e64c86b5 100644 --- a/rabbitmq/consumer.ts +++ b/rabbitmq/consumer.ts @@ -1,27 +1,27 @@ -//@ts-nocheck +// @ts-nocheck +export = {}; +// const { AMQPClient } = require('@cloudamqp/amqp-client'); -const { AMQPClient } = require('@cloudamqp/amqp-client'); +// async function initRabbitMQ() { +// try { +// const amqp = new AMQPClient(process.env.RABBITMQ_URL); +// const conn = await amqp.connect(); +// const channel = await conn.channel(); +// const queue = await channel.queue('shortened'); // RabbitMQChannel.SHORTENED +// await queue.subscribe({ noAck: true }, consumer); +// console.log('RabittMQ is running'); +// } catch (error) { +// console.error('RabittMQ', error); +// error.connection.close(); +// } +// } -async function initRabbitMQ() { - try { - const amqp = new AMQPClient(process.env.RABBITMQ_URL); - const conn = await amqp.connect(); - const channel = await conn.channel(); - const queue = await channel.queue('shortened'); // RabbitMQChannel.SHORTENED - await queue.subscribe({ noAck: true }, consumer); - console.log('RabittMQ is running'); - } catch (error) { - console.error('RabittMQ', error); - error.connection.close(); - } -} - -const consumer = async (msg) => { - // console.log('RabittMQ received: ', msg.bodyToString()); - console.log(JSON.parse(msg.bodyToString())); - await setTimeout(() => { - console.log('processed', msg.bodyToString()); - }, 5000); - // await consumer.cancel(); -}; -module.exports = { initRabbitMQ }; +// const consumer = async (msg) => { +// // console.log('RabittMQ received: ', msg.bodyToString()); +// console.log(JSON.parse(msg.bodyToString())); +// await setTimeout(() => { +// console.log('processed', msg.bodyToString()); +// }, 5000); +// // await consumer.cancel(); +// }; +// module.exports = { initRabbitMQ };