Skip to content

Latest commit

 

History

History
153 lines (116 loc) · 5.63 KB

README.md

File metadata and controls

153 lines (116 loc) · 5.63 KB

Nest Logo

A refined and optimized codebase for setting up NestJS microservices.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Description 📜

nestifined-ms-framework is a refined and optimized codebase for setting up NestJS microservices.

Features ✨

  • 🐳 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.

Installation 🛠️

$ yarn install

Running the app 🚀

# development
$ yarn run start
# watch mode
$ yarn run start:dev
# production mode
$ yarn run start:prod

Test 🧪

# unit tests
$ yarn run test

# e2e tests
$ yarn run test:e2e

# test coverage
$ yarn run test:cov

Linting 🧹

# lint the code
$ yarn run lint

# lint and fix the code
$ yarn run lint:fix

Docker 🐳

# 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 and Push Docker Image to Docker Hub 🐋

# 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

Apply Kubernetes Configurations ☸️

# Development Environment
kubectl apply -k k8s/development/

# Staging Environment
kubectl apply -k k8s/staging/

# Production Environment
kubectl apply -k k8s/production/

Husky 🐶

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.

Environment Variables 🌍

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

Support ❤️

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!

Stay in Touch 📬

License 📄

This project is MIT licensed.