Compare commits
No commits in common. "429ddebf0217ce801994f07acf08dc79f5588a15" and "46f78fa563b3e98501b2eea267d4440f1ea17f0e" have entirely different histories.
429ddebf02
...
46f78fa563
7 changed files with 16 additions and 50 deletions
|
@ -8,12 +8,15 @@ 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: kfda89/todorabbit:latest
|
||||
image: todorabbit:latest
|
||||
restart: always
|
||||
ports:
|
||||
- 5672:5672
|
||||
|
@ -21,6 +24,9 @@ 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
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
# 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"]
|
|
@ -4,7 +4,7 @@
|
|||
"description": "",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"dev": "node dist/main.js"
|
||||
"dev": "tsc && nodemon dist/main.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
|
|
@ -4,11 +4,11 @@ import { MongoDbModel } from "./mongodb/MongoDb";
|
|||
|
||||
export class NotificationService {
|
||||
rabbitmq: RabbitMQ;
|
||||
mongoModel: MongoDbModel;
|
||||
mongoModle: MongoDbModel;
|
||||
|
||||
constructor() {
|
||||
this.rabbitmq = new RabbitMQ();
|
||||
this.mongoModel = new MongoDbModel();
|
||||
this.mongoModle = new MongoDbModel();
|
||||
this.startListener();
|
||||
}
|
||||
|
||||
|
@ -20,11 +20,11 @@ export class NotificationService {
|
|||
}
|
||||
|
||||
async newMessageValidator(message: ITodo) {
|
||||
const todo = await this.mongoModel.getTodoById(message._id.toString());
|
||||
const todo = await this.mongoModle.getTodoById(message._id.toString());
|
||||
if (todo) {
|
||||
const due_date = new Date(todo.due_date);
|
||||
if (todo.status === "pending" && due_date > new Date()) {
|
||||
await this.mongoModel.updateTodoStatus(todo);
|
||||
await this.mongoModle.updateTodoStatus(todo);
|
||||
await this.sendNotification(todo); // Send notification to user
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
# 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 3000
|
||||
|
||||
# Start the application in development mode
|
||||
CMD ["npm", "run", "dev"]
|
|
@ -4,7 +4,7 @@
|
|||
"description": "",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"dev": "node dist/main.js"
|
||||
"dev": "nodemon dist/main.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
|
|
@ -58,7 +58,7 @@ export class RabbitMQ {
|
|||
headers: { "x-delay": delayTimeForQueue },
|
||||
};
|
||||
try {
|
||||
this.channel.publish(
|
||||
await this.channel.publish(
|
||||
this.exchange,
|
||||
this.queue,
|
||||
Buffer.from(message),
|
||||
|
@ -73,6 +73,6 @@ export class RabbitMQ {
|
|||
|
||||
calculateDelayTimeForQueue(payload: ITodo) {
|
||||
const delayTime = payload.due_date.getTime() - Date.now();
|
||||
return delayTime;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue