Template del servicio de SIM

This commit is contained in:
2026-01-08 13:36:52 +01:00
parent a49469cd9e
commit 68631ff18f
33 changed files with 5138 additions and 1 deletions

View File

@@ -0,0 +1,43 @@
import client, { ChannelModel, connect, Connection } from "amqplib"
import { env } from "config/env"
import { Channel } from "node:diagnostics_channel"
const rmqUser = env.RABBITMQ_USER
const rmqPass = env.RABBITMQ_PASSWORD
const rmqHost = env.RABBITMQ_HOST
const rmqPort = Number(env.RABBITMQ_PORT)
const rmqSecure = env.RABBITMQ_SECURE
class RabbitConnection {
connection?: Connection
channel?: Channel
connected: Boolean = false
protected async createConnection(): Promise<ChannelModel> {
const { hostname, port, secure } = { hostname: rmqHost, port: rmqPort, secure: rmqSecure }
const { username, password } = { username: rmqUser, password: rmqPass };
const protocol = secure ? 'amqps' : 'amqp';
const connection = await connect({
protocol,
hostname,
port,
username,
password
});
connection.on('error', (error: unknown) => {
console.error(`[EVENT BUS] Rabbitmq connection error :: ${error}`);
Promise.reject(error);
});
return connection;
}
}
while (true) {
console.log("test")
}
export default {}