This is a simple Node.js microservice using MySQL for data storage and RabbitMQ for event-driven communication. No CI/CD pipelines as tests of any kind too.
- MySQL database
- MongoDB database
- RabbitMQ working instance
- pnpm package manager
-
Clone the repository:
git clone https://github.com/ioneluoooo/Microservices.git cd Microservices
-
Install dependencies
pnpm install
-
Run the application
pnpm start
- Endpoint:
GET /api/products
- Description: Get a list of all products.
- Example Response:
[ { "id": 1, "title": "Product 1", "likes": 10 }, { "id": 2, "title": "Product 2", "likes": 5 } ]
- Endpoint:
POST /api/products
- Description: Creates a new product.
- Request Body:
{ "title": "New Product" }
- Example Response:
{ "id": 3, "title": "New Product", "likes": 0 }
- Endpoint:
POST /api/products/:id/like
- Description: Increase the number of likes for a product.
- Example Response:
{ "id": 3, "title": "New Product", "likes": 1 }
- Endpoint:
GET /api/products/:id
- Description: Get details of a specific product by ID.
- Example Response:
{ "id": 3, "title": "New Product", "likes": 1 }
- Endpoint:
PUT /api/products/:id
- Description: Update details of a specific product by ID.
- Request Body:
{ "title": "Updated Product" }
- Example Response:
{ "id": 3, "title": "Updated Product", "likes": 1
}
- Endpoint:
DELETE /api/products/:id
- Description: Delete a product by ID.
- Example Response:
{ "affected": 1, "raw": null, "generatedMaps": [], "generatedColumns": [] }