Skip to content

Commit

Permalink
added .env file for RabbitMQ
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinLemon112 committed Nov 2, 2023
1 parent f4e1763 commit 99228f4
Show file tree
Hide file tree
Showing 51 changed files with 51 additions and 11 deletions.
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"dependencies": {
"amqplib": "^0.10.3",
"dotenv": "^16.3.1",
"typescript-coverage-report": "^0.7.0"
},
"scripts": {
Expand Down
8 changes: 7 additions & 1 deletion src/notification/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
Object.defineProperty(exports, "__esModule", { value: true });
// Import the necessary modules
var amqplib = require("amqplib");
var dotenv = require("dotenv");
// Load environment variables from the .env file
dotenv.config();
// Access the environment variables
var rabbitMqUsername = process.env.RABBITMQ_USERNAME;
var rabbitMqPassword = process.env.RABBITMQ_PASSWORD;
function connectToRabbitMQ() {
return __awaiter(this, void 0, void 0, function () {
var connection, channel, queueName, message, sendMessages, consumer, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 6, , 7]);
return [4 /*yield*/, amqplib.connect('amqp://luminosityleds:Lumi-123@localhost:5672', {
return [4 /*yield*/, amqplib.connect("amqp://".concat(rabbitMqUsername, ":").concat(rabbitMqPassword, "@localhost:5672"), {
heartbeat: 10,
})];
case 1:
Expand Down
10 changes: 9 additions & 1 deletion src/notification/connection.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
// Import the necessary modules
import * as amqplib from 'amqplib';
import * as dotenv from 'dotenv';

// Load environment variables from the .env file
dotenv.config();

// Access the environment variables
const rabbitMqUsername = process.env.RABBITMQ_USERNAME;
const rabbitMqPassword = process.env.RABBITMQ_PASSWORD;

async function connectToRabbitMQ() {
try {

// Replace 'username' and 'password' with your RabbitMQ credentials
const connection: amqplib.Connection = await amqplib.connect(
'amqp://luminosityleds:Lumi-123@localhost:5672',
`amqp://${rabbitMqUsername}:${rabbitMqPassword}@localhost:5672`,
{
heartbeat: 10,
}
Expand Down
7 changes: 2 additions & 5 deletions src/notification/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ services:
image: rabbitmq:3.9.13-management-alpine
container_name: 'rabbitmq'
restart: always
environment:
- "RABBITMQ_DEFAULT_PASS=Lumi-123"
- "RABBITMQ_DEFAULT_USER=luminosityleds"
env_file: ".env"
ports:
- "15672:15672"
- "5672:5672"
Expand All @@ -15,7 +13,6 @@ services:
volumes:
- ./rabbitmq-data:/var/lib/rabbitmq


networks:
rabbitmq_go_net:
driver: bridge
driver: bridge
1 change: 0 additions & 1 deletion src/notification/rabbitmq-data/mnesia/[email protected]

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions src/notification/rabbitmq-data/mnesia/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
15
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[drop_unroutable_metric,empty_basic_get_metric,implicit_default_bindings,
maintenance_mode_status,quorum_queue,stream_queue,user_limits,
virtual_host_metadata].
1 change: 1 addition & 0 deletions src/notification/rabbitmq-data/mnesia/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
15
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{[rabbit@e62134c482ef],[rabbit@e62134c482ef]}.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[rabbit@e62134c482ef].
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cXM
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cXM
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ define-properties@^1.1.3, define-properties@^1.2.0:
has-property-descriptors "^1.0.0"
object-keys "^1.1.1"

dotenv@^16.3.1:
version "16.3.1"
resolved "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz"
integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==

emoji-regex@^8.0.0:
version "8.0.0"
resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz"
Expand Down

0 comments on commit 99228f4

Please sign in to comment.