UNPKG

event-message-broker

Version:

A Message Bus that uses AWS Stack and RabbitMQ

34 lines (33 loc) 1.77 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.RabbitMqContext = void 0; const amqplib_1 = __importDefault(require("amqplib")); const configurations_1 = require("../../application/utils/configurations"); class RabbitMqContext { static configureContext() { return __awaiter(this, void 0, void 0, function* () { const host = process.env.RABBITMQ_HOST; const port = process.env.RABBITMQ_PORT; const user = process.env.RABBITMQ_USER; const pass = process.env.RABBITMQ_PASS; const connectionString = `amqp://${user}:${pass}@${host}:${port}`; const connection = yield amqplib_1.default.connect(connectionString); const channel = yield connection.createChannel(); channel.prefetch(configurations_1.Configuration.prefetch); return channel; }); } } exports.RabbitMqContext = RabbitMqContext;