This repository contains the implementation of two services, M1 and M2, that communicate with each other using RabbitMQ. The M1 service receives HTTP requests, processes them, and sends tasks to the M2 service through a RabbitMQ queue. The M2 service then processes these tasks and sends the results back to M1.
- RabbitMQ Integration: Seamless integration with RabbitMQ for inter-service communication.
- Rate Limiting: Protects the service from being overwhelmed by too many requests.
- Health Check: Endpoint to check the health status of the services.
- Error Handling: Robust error handling and logging mechanism.
- Configurable: Centralized configuration loading for easy adjustments.
- Logging: Comprehensive logging using Winston with separate logs for errors and combined logs.
- Node.js
- RabbitMQ server
-
Clone the Repository:
git clone https://github.com/NilaierMusic/Custom-HTTP-Request-Processing.git cd custom_http_request_processing
-
Install Dependencies:
npm install
-
Set Configuration: Configurations are located in the
src/config
folder. To use a specific configuration, set theNODE_ENV
variable to the name of the desired configuration file (without the.js
extension).-
Windows:
set NODE_ENV=configname
-
Linux/MacOS:
export NODE_ENV=configname
Alternatively, you can use a
.env
file placed in the root directory of the project as a fallback or in conjunction with the above method. For more information, check.env.example
file in repository's docs folder. -
-
Start the Services:
- Start M1 service:
npm run start:m1
- Start M2 service:
npm run start:m2
- Start BOTH services:
npm run start:all
- Start M1 service:
-
Verify: Navigate to
http://localhost:3000/health
(or the port you've configured) in your browser or use a tool likecurl
to ensure the service is running and healthy.
Run the tests using the following command:
npm test
Contributions are welcome! Please read the CONTRIBUTING.md for details on how to contribute.
This project is licensed under the MIT License. See the LICENSE.md file for details.
- RabbitMQ and Node.js communities for their comprehensive documentation and resources.