Rating Service
375
A production-ready NestJS microservice for handling product ratings in e-commerce systems.
version: '3.8'
services:
rating-service:
image: peekaboo51490/rating-service:latest
ports:
- "3000:3000"
environment:
- DATABASE_URL=postgresql://user:pass@postgres:5432/rating_service
- PORT=3000
- NODE_ENV=production
depends_on:
- postgres
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/rating/api/v1/health/liveness')"]
interval: 30s
timeout: 3s
retries: 3
postgres:
image: postgres:15-alpine
environment:
- POSTGRES_DB=rating_service
- POSTGRES_USER=rating
- POSTGRES_PASSWORD=rating
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
| Variable | Description | Default | Required |
|---|---|---|---|
DATABASE_URL | PostgreSQL connection string | - | Yes |
PORT | Application port | 3000 | No |
NODE_ENV | Environment mode | production | No |
ALLOWED_ORIGINS | CORS allowed origins (comma-separated) | * | No |
| Method | Endpoint | Description |
|---|---|---|
| POST | /rating/api/v1/product/{productId} | Add a rating for a product |
| GET | /rating/api/v1/product/{productId} | Get rating summary for a product |
| Method | Endpoint | Description |
|---|---|---|
| GET | /rating/api/v1/health | Full health check (includes database) |
| GET | /rating/api/v1/health/liveness | Kubernetes liveness probe |
| GET | /rating/api/v1/health/readiness | Kubernetes readiness probe |
| GET | /rating/api/v1/metrics | Prometheus metrics |
| GET | /api-docs | Swagger API documentation |
curl -X POST http://localhost:3000/rating/api/v1/product/123 \
-H "Content-Type: application/json" \
-d '{"rating": 4.5}'
Response:
{
"message": "Rating added successfully"
}
curl http://localhost:3000/rating/api/v1/product/123
Response:
{
"productId": 123,
"averageRating": 4.5,
"totalRatings": 1
}
The service includes comprehensive health checks:
For issues and feature requests, please use the GitHub issue tracker.
Content type
Image
Digest
sha256:2017cd4bb…
Size
87.8 MB
Last updated
6 months ago
docker pull peekaboo51490/emart-rating-service:b85fca3