Account service for icommerce, this is the example of creating extensible & scalable nodeJS backend microservices. This project is follow The Twelve-Factor App
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
This solution follow Microservice, Services must be loosely coupled so that they can be developed, deployed and scaled independently and different services have different data storage requirements
https://www.getpostman.com/collections/c52b25bcf546c568e03a
Create Postman environment: development
Add 3 variables:
- token: null
- INVENTORY_URL: http://localhost:3001
- ACCOUNT_URL: http://localhost:3000
.
├── migrations
│ ├── factories
│ └── seeds
├── src
│ ├── auth
│ │ ├── controllers
│ │ ├── guards
│ │ ├── services
│ │ └── strategies # Passport Strategies
│ └── user
│ ├── controllers
│ ├── entities
│ └── services
└── test
We use 3 Postgres Databases, each microservice’s persistent data private to that service and accessible only via its API. A service’s transactions only involve its database.
- User Register SD
- User Login SD
What things you need to install & start development
- Node.js v10 or above
- Docker & Docker Compose to start Redis & PostgresDB
- Start docker containers
docker-compose up -d
- Install all package using yarn
yarn install
- Running the app
# development
$ yarn start
# watch mode
$ yarn start:dev
This project use Jest & NestJS test
This project only have 2 sample tests for Controller & Service
yarn test
Run end to end test, you should stop the development server first
yarn test:e2e
Get the coverage report
yarn test:cov
We using eslint standard
yarn lint
All the environment config store in .env
# Development will enable Data Synchronize
NODE_ENV=development
# Application/Service
PORT=3000
## USER_SERVICE
USER_SERVICE_HOST=localhost
USER_SERVICE_PORT=4000
## AUTH_SERVICE
AUTH_SERVICE_HOST=localhost
AUTH_SERVICE_PORT=4010
# Database
POSTGRES_HOST=localhost
POSTGRES_PORT=5455
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=account
# JWT Config
JWT_SECRET=thisIsSecre(t)
JWT_EXPIRES_IN=1h
http://localhost:3000/docs
- Author - duminhtam@gmail.com
This project is MIT licensed.