This is a NestJS project that uses the following technology stack:
- NestJS: A framework for building efficient, scalable Node.js server-side applications.
- TypeScript: A superset of JavaScript that adds static types and other features.
- MongoDB: A NoSQL database used for data storage.
- Jest: A testing framework for JavaScript and TypeScript.
- Supertest: A library for testing HTTP servers.
- ESLint: A tool for checking the quality of JavaScript and TypeScript code.
- Prettier: A tool for automatically formatting JavaScript and TypeScript code.
- Husky: A tool for managing git hooks, which can automatically run lint and tests before committing code.
- cross-env: A library for setting environment variables, which can maintain consistent behavior across different operating systems.
- redis: A in-memory data structure store, used as a cache.
- swagger: A tool for documenting APIs.
- nestjs-i18n: A library for internationalization.
- cls-hooked: A library for managing context in asynchronous operations.
- pm2: A process manager for Node.js applications.
- user module - CRUD, RBAC
- auth module - login, register, delete, token and refresh token
- api doc - swagger
- i18n - internationalization
# if you don't have pnpm installed, you can install it with npm
npm i -g pnpm
pnpm install
Additionally, you must install MongoDB and Redis in advance.
# development
pnpm start
# watch mode
pnpm dev
# production mode
pnpm build
pnpm start:prod
# unit tests
pnpm test
# e2e tests
pnpm test:e2e
# test coverage
pnpm test:cov
pnpm test:e2e-cov
When deploying the project with Docker, you need to replace the environment variables in docker-compose.yml
:
version: '3'
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- '3000:3000'
depends_on:
- mongodb
- redis
environment:
- MONGODB_URL=mongodb://mongodb:27017/mongodb?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.2.0
- NEST_SERVER_PORT=3000
- NEST_CORS_DOMAINS=http://localhost:3001,http://localhost:8080
- REDIS_URL=redis
- REDIS_PORT=6379
- NODE_ENV=production
volumes:
- D:/docker-data-map/logs:/app/logs
restart: always
mongodb:
image: mongo
ports:
- '27017:27017'
volumes:
- D:/software/mongodb/test:/data/db
redis:
image: redis:alpine
ports:
- '6379:6379'
volumes:
- D:/docker-data-map/redis/data:/data
command: redis-server --appendonly yes
Then, execute docker-compose build
and docker-compose up -d
to deploy the project.