From 429ddebf0217ce801994f07acf08dc79f5588a15 Mon Sep 17 00:00:00 2001 From: Kfir Dayan Date: Sun, 9 Jul 2023 11:10:08 +0300 Subject: [PATCH] clening --- infra/docker/docker-compose.yaml | 10 ++-------- notification-service/Dockerfile | 20 ++++++++++++++++++++ notification-service/package.json | 2 +- notification-service/src/main.ts | 8 ++++---- 4 files changed, 27 insertions(+), 13 deletions(-) create mode 100644 notification-service/Dockerfile diff --git a/infra/docker/docker-compose.yaml b/infra/docker/docker-compose.yaml index da27a80..be78535 100644 --- a/infra/docker/docker-compose.yaml +++ b/infra/docker/docker-compose.yaml @@ -8,15 +8,12 @@ services: volumes: - mongodb_vol:/data/db - ./mongo-init-scripts/init.js:/docker-entrypoint-initdb.d/mongo-init.js - environment: - - MONGO_INITDB_DATABASE=${MONGO_INITDB_DATABASE} - - MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME} - - MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD} platform: linux/arm64/v8 expose: - 27017 + rabbitmq: - image: todorabbit:latest + image: kfda89/todorabbit:latest restart: always ports: - 5672:5672 @@ -24,9 +21,6 @@ services: volumes: - rabbitmq_volume:/var/lib/rabbitmq - ./rabbitmq-init-scripts/init.sh:/docker-entrypoint-initdb.d/init.sh - environment: - - RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER} - - RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS} expose: - 5672 - 15672 diff --git a/notification-service/Dockerfile b/notification-service/Dockerfile new file mode 100644 index 0000000..24fba97 --- /dev/null +++ b/notification-service/Dockerfile @@ -0,0 +1,20 @@ +# Use the official Node.js 14 image as the base +FROM node:14 + +# Set the working directory in the container +WORKDIR /app + +# Copy package.json and package-lock.json to the container +COPY package*.json ./ + +# Install project dependencies +RUN npm install + +# Copy the rest of the application code to the container +COPY . . + +# Expose the port on which your Express app listens +EXPOSE 4000 + +# Start the application in development mode +CMD ["npm", "run", "dev"] diff --git a/notification-service/package.json b/notification-service/package.json index 7b259dc..0147c40 100644 --- a/notification-service/package.json +++ b/notification-service/package.json @@ -4,7 +4,7 @@ "description": "", "main": "main.js", "scripts": { - "dev": "tsc && nodemon dist/main.js" + "dev": "node dist/main.js" }, "keywords": [], "author": "", diff --git a/notification-service/src/main.ts b/notification-service/src/main.ts index 6b2dc83..c895981 100644 --- a/notification-service/src/main.ts +++ b/notification-service/src/main.ts @@ -4,11 +4,11 @@ import { MongoDbModel } from "./mongodb/MongoDb"; export class NotificationService { rabbitmq: RabbitMQ; - mongoModle: MongoDbModel; + mongoModel: MongoDbModel; constructor() { this.rabbitmq = new RabbitMQ(); - this.mongoModle = new MongoDbModel(); + this.mongoModel = new MongoDbModel(); this.startListener(); } @@ -20,11 +20,11 @@ export class NotificationService { } async newMessageValidator(message: ITodo) { - const todo = await this.mongoModle.getTodoById(message._id.toString()); + const todo = await this.mongoModel.getTodoById(message._id.toString()); if (todo) { const due_date = new Date(todo.due_date); if (todo.status === "pending" && due_date > new Date()) { - await this.mongoModle.updateTodoStatus(todo); + await this.mongoModel.updateTodoStatus(todo); await this.sendNotification(todo); // Send notification to user } }