A refined and optimized codebase for setting up NestJS microservices.
nestifined-ms-framework is a refined and optimized codebase for setting up NestJS microservices.
- 🐳 Docker: Containerize the application using Docker.
- ☸️ Kubernetes: Deployment configurations for development, staging, and production environments.
- 🗃️ TypeORM: Integration with TypeORM for database interactions.
- ⚡ Redis: Caching support using Redis.
- 📨 RabbitMQ: Messaging support using RabbitMQ.
- 📄 Swagger: API documentation using Swagger.
- 🐶 Husky: Git hooks management using Husky.
- 🧹 Linting and Formatting: ESLint and Prettier for code linting and formatting.
- 🧪 Testing: Unit and e2e testing using Jest.
- 📜 Logging: Logging using Winston with daily rotate file support.
- 🔧 Environment Configuration: Environment variable management using dotenv.
$ yarn install
# development
$ yarn run start
# watch mode
$ yarn run start:dev
# production mode
$ yarn run start:prod
# unit tests
$ yarn run test
# e2e tests
$ yarn run test:e2e
# test coverage
$ yarn run test:cov
# lint the code
$ yarn run lint
# lint and fix the code
$ yarn run lint:fix
# Building the Docker Image
docker build -t nestifined-ms-framework .
# Running the Docker Container
docker run -p 3000:3000 --env-file .env nestifined-ms-framework
# Build the Docker image
docker build -t your-docker-username/nestifined-ms-framework:latest .
# Push the Docker image to a container registry
docker push your-docker-username/nestifined-ms-framework:latest
# Development Environment
kubectl apply -k k8s/development/
# Staging Environment
kubectl apply -k k8s/staging/
# Production Environment
kubectl apply -k k8s/production/
Husky is used to manage Git hooks. The following hooks are configured:
- pre-commit: Runs lint-staged to lint and format code before committing.
- commit-msg: Ensures commit messages follow the conventional commit format.
- post-commit: Runs after a commit is made.
- pre-push: Runs before pushing code to the repository.
- post-merge: Runs after merging branches.
- post-checkout: Runs after checking out a branch.
- prepare-commit-msg: Runs before the commit message editor is opened.
- post-rewrite: Runs after a commit is rewritten.
- pre-rebase: Runs before rebasing branches.
The application uses environment variables for configuration. Create a .env
file in the root of the project and add the following variables:
NODE_ENV=development
APP_NAME=MyApp
HOST=127.0.0.1
PORT=3000
CORS={"origin": ["http://example1.com", "/\\.example2\\.com$/"], "methods": ["GET", "POST"], "credentials": true}
API_PREFIX=api
RELEASE=1.0.0
S2S_TRANSPORT=RABBITMQ
S2S_REDIS_URL=redis://localhost:6379
S2S_RABBITMQ_URL=amqp://localhost:5672
S2S_RABBITMQ_QUEUE=my_queue
This project is an MIT-licensed open source initiative. It thrives thanks to the contributions from the amazing community. I welcome and encourage you to contribute by creating pull requests and helping improve the project. Your support and involvement are greatly appreciated!
- Author: Mahdi Rashidi
- LinkedIn: Visit My Profile
This project is MIT licensed.