Basic microservices project that includes a gateway (api-gateway) and 3 microservices (user/product/client) and a messaging queue
This variation utilizes RabbitMQ as the messaging queue so if one microservice goes down, it will receive messages when it gets back up.
- Install Node.js
- Install RabbitMQ or run it in a Docker container with the included compose file. Alternatively you can use their cloud solution at CloudAMQP
- Clone the repository
git clone https://github.com/19EB/microservices-base
- Install dependencies on api-gateway
cd api-gateway npm install
- Install dependencies on each microservice (user, product and client)
cd services/<microservice> npm install
This project uses the following environment variables:
# Port PORT=8000 # User service USER_SERVICE_URL='http://localhost:8001' # Client service CLIENT_SERVICE_URL='http://localhost:8002' # Product service PRODUCT_SERVICE_URL='http://localhost:8003'
# Database DB='' # Service port PORT=8001 # RabbitMQ configuration (use local or cloud url here) MESSAGE_BROKER_URL=''
Running the project
- If you plan on using Docker for running RabbitMQ, I have included “rabbitmq” folder that contains the docker-compose file.
cd rabbitmq docker-compose up -d
- Start each microservice from its own directory
cd services/<microservice> npm run dev
cd services/<microservice> npm start
- Start the api-gateway
cd api-gateway npm start or npm run dev
The project has couple endpoints to ping each other and one normal endpoint.
This project is licensed under the MIT License