This repository provides a basic setup for building a microservice using NestJS. It is designed to serve as a starting point for projects with a focus on modularity and scalability.
- Microservice Architecture:
- Leverage NestJS microservices module.
- Communicate using NATS messaging system.
- Configuration Management:
- Centralized and extensible configuration using @nestjs/config.
- Ready-to-Use Setup:
- Pre-configured scripts for building, testing, and deploying the service.
- Node.js (v16 or higher)
- NATS (v2 or higher)
git clone https://github.com/Jszigeti/microservice-setup.git
cd microservice-setupnpm installCreate a .env file in the root directory and define the following variables:
NATS_DNS=XXX.XXX.X.XX
NATS_PORT=XXXXReplace XXX.XXX.X.XX and XXXX with your NATS server's address and port.
npm run start:devnpm run build
npm run start:prod| Script | Description |
|---|---|
npm run build |
Build the application |
npm run start |
Start the application in production mode |
npm run start:dev |
Start the application in development mode |
npm run lint |
Run linting and auto-fix issues |
npm run format |
Format code with Prettier |
microservice-setup/
├── src/
│ ├── app.controller.ts # Application controller
│ ├── app.module.ts # Application module
│ ├── app.service.ts # Application service
│ └── main.ts # Application entry point
├── .env # Environment variables
├── package.json # Project dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # Project documentation
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is UNLICENSED and provided as a basic example. Feel free to adapt it to your needs.
- Author: Jonas Szigeti
- GitHub: https://github.com/Jszigeti
- Issues: Open an issue