Simple e-commerce task
- User can login & register.
- User can add products in the cart.
- User can get his cart summary.
- docker-compose support
- Elasticsearch as a database.
- NATs messaging system for services transportation.
- Redis for caching
- POST /api/register body:{name,email,password}
- POST /api/login body:{email,password}
- POST /api/products/create body:{
name: {type: "string"},
url: {type: "string"},
sku: {type: "string"},
barcode: {type: "string"},
brand: {type: "string"},
category: {type: "string"}
}
headers:{Authorization:<useer_token>}
- POST /api/cart/add body:{productId} headers:{Authorization:<useer_token>}
- GET /api/cart headers:{Authorization:<useer_token>}
- POST /api/cart/clear headers:{Authorization:<useer_token>}
# Install dependencies
npm install
# Start developing with REPL
npm run dev
# Start production
npm start
# Run unit tests
npm test
# Run ESLint
npm run lint
# Run Prettier
npm run prettier
-
Start with docker-compose:
node dc:up
ORdocker-compose up -d
It starts all services in separated containers, a Redis server for caching and a Traefik reverse proxy. All nodes communicate via NATs transporter.
-
Open the http://docker-ip:3000
- moleculer - Microservices framework for NodeJS
- moleculer-web - Official API Gateway service for Moleculer
- nats - NATS transport driver for Moleculer (optional)
- elasticsearch - ELASTICSEARCH as database
- ioredis - REDIS caching
- jsonwebtoken - JWT user autheentication
moleculer.config.js
- Moleculer ServiceBroker configuration file.services/
- This folder contains the services.
$ npm test