Skip to content

Jszigeti/microservice-setup

Repository files navigation

MS with NestJS Example

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.


Features

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

Requirements

  • Node.js (v16 or higher)
  • NATS (v2 or higher)

Getting Started

Clone the Repository

git clone https://github.com/Jszigeti/microservice-setup.git
cd microservice-setup

Install Dependencies

npm install

Configure Environment Variables

Create a .env file in the root directory and define the following variables:

NATS_DNS=XXX.XXX.X.XX
NATS_PORT=XXXX

Replace XXX.XXX.X.XX and XXXX with your NATS server's address and port.


Running the Application

Development Mode

npm run start:dev

Production Mode

npm run build
npm run start:prod

Scripts

Key Commands

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

Project Structure

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

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.


License

This project is UNLICENSED and provided as a basic example. Feel free to adapt it to your needs.


Contact

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published