UNPKG

event-message-broker

Version:

A Message Bus that uses AWS Stack and RabbitMQ

27 lines (26 loc) 1.43 kB
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()); }); }; import amqp from "amqplib"; import { Configuration } from "../../application/utils/configurations"; export 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 amqp.connect(connectionString); const channel = yield connection.createChannel(); channel.prefetch(Configuration.prefetch); return channel; }); } }