done for now
This commit is contained in:
parent
e8265f5fe3
commit
37f027cb1c
2 changed files with 15 additions and 7 deletions
20
README.md
20
README.md
|
@ -2,11 +2,12 @@
|
||||||
|
|
||||||
This README.md file provides instructions for setting up and running various components of the project, including MongoDB, SQS, NotificationService, and TodoService. Please follow the steps below to get started.
|
This README.md file provides instructions for setting up and running various components of the project, including MongoDB, SQS, NotificationService, and TodoService. Please follow the steps below to get started.
|
||||||
|
|
||||||
## MongoDB/Docker
|
## MongoDB/Docker && RabbitMQ/Docker
|
||||||
|
|
||||||
1. Install MongoDB if you haven't already.
|
1. Install MongoDB if you haven't already.
|
||||||
2. Navigate to the `/infra/docker/docker-compose` directory.
|
2. Navigate to the `/infra/docker/docker-compose` directory.
|
||||||
3. Run the following command to start MongoDB using Docker Compose:
|
3. Make sure to add .env by copying .env.example and filling in the values.
|
||||||
|
4. Run the following command to start MongoDB using Docker Compose:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
|
@ -15,9 +16,7 @@ This README.md file provides instructions for setting up and running various com
|
||||||
## NotificationService
|
## NotificationService
|
||||||
|
|
||||||
Before running the NotificationService, ensure that you have Node.js, TypeScript (tsc), and npm installed.
|
Before running the NotificationService, ensure that you have Node.js, TypeScript (tsc), and npm installed.
|
||||||
|
|
||||||
Navigate to the /notification-service directory.
|
Navigate to the /notification-service directory.
|
||||||
|
|
||||||
Run the following command to install the dependencies:
|
Run the following command to install the dependencies:
|
||||||
|
|
||||||
```npm
|
```npm
|
||||||
|
@ -33,9 +32,7 @@ npm run dev
|
||||||
## TodoService
|
## TodoService
|
||||||
|
|
||||||
Before running the TodoService, ensure that you have Node.js, TypeScript (tsc) and npm installed.
|
Before running the TodoService, ensure that you have Node.js, TypeScript (tsc) and npm installed.
|
||||||
|
|
||||||
Navigate to the /todo-service directory.
|
Navigate to the /todo-service directory.
|
||||||
|
|
||||||
Run the following command to install the dependencies:
|
Run the following command to install the dependencies:
|
||||||
|
|
||||||
```npm
|
```npm
|
||||||
|
@ -51,3 +48,14 @@ npm run dev
|
||||||
## Requests
|
## Requests
|
||||||
|
|
||||||
Examples are located in request.http - can be run in VSCode with the REST Client extension.
|
Examples are located in request.http - can be run in VSCode with the REST Client extension.
|
||||||
|
|
||||||
|
## notification-service business logic
|
||||||
|
|
||||||
|
1. When a new todo is created, the notification-service will receive a message from the todo-service with delay time due_date - current_time.
|
||||||
|
2. The notification-service will then send a message to rabbitmq with the delay time.
|
||||||
|
3. When the delay time is up, the notification-service will receive a message from rabbitmq and send a notification to the user by the following logic:
|
||||||
|
a. If the todo is no "pending" status and due_date is smaller then current time, send a notification to the user.
|
||||||
|
b. If the todo is already completed, do nothing.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ export class NotificationService {
|
||||||
|
|
||||||
async newMessageValidator(message: ITodo) {
|
async newMessageValidator(message: ITodo) {
|
||||||
try {
|
try {
|
||||||
const todo = await this.mongoModel.getTodoById(message._id.toString());
|
const todo: ITodo | void = await this.mongoModel.getTodoById(message._id.toString());
|
||||||
if (todo) {
|
if (todo) {
|
||||||
const due_date = new Date(todo.due_date);
|
const due_date = new Date(todo.due_date);
|
||||||
if (todo.status === "pending" && due_date > this.currentDate.getDate()) {
|
if (todo.status === "pending" && due_date > this.currentDate.getDate()) {
|
||||||
|
|
Loading…
Reference in a new issue