Skip to content

agodin3z/nestjs-cqrs-boilerplate

Repository files navigation

Nest Logo

A NestJS API boilerplate using DDD + CQRS + Docker.

Node Version Conventional Commits Linted with Biome Styled with Prettier

Tech Stack

Name Description
NestJS A progressive Node.js framework for building efficient, reliable and scalable server-side applications.
Docker A platform designed to help developers build, share, and run modern applications.
Husky Git hooks made easy dog woof!
Biome Format, lint, and more in a fraction of a second. code.
Prettier An opinionated code formatter.
Lint Staged Run linters on git staged files.

Prerequisites

  • Volta* - a node/npm version manager
  • Docker** - An one-click-install application that enables you to build and share containerized applications and microservices.
    • Docker Compose - Plugin for running multi-container Docker applications

* Alternatives to Volta: n or nvm

** "Alternative" to Docker: orbstack

Getting Started

Enviroment config

Create a copy of .env.example with the name .env and placed it at the root of the project

  cp .env.example .env

Replace its values with your own credentials.

Install Dependencies

Run the following commands to install all dependencies:

  volta install node
  volta install npm@bundled
  npm i

Development server

Run npm run start:dev to start a development server that watch for changes. For a debug server use: npm run start:debug

Build for production

Run npm run build to compile for production. Then run npm run start:prod to start a production server.

Check out the deployment documentation for more information.

Using Dockerfile

Run make dev to build and start development docker containers from docker-compose-dev.yml, or run make deploy to build and start production docker containers from docker-compose.yml.

Project Folder Structure

.
└── nestjs-cqrs-boilerplate     # Project root
    ├── .husky/                 # Git hooks
    ├── .vscode/                # VSCode settings & recommended extensions
    ├── dist/                   # API compilation
    ├── node_modules/           # NPM Packages
    ├── src/                    # Source: DDD + Clean Arch + CQRS
    │   ├── application/        # Application Layer: Commands, Queries & Events
    │   ├── domain/             # Domain Layer: Services, Entities, etc
    │   ├── infraestructure/    # Infraestructure Layer: Server Config, Envs, Adapters, etc
    │   └── interface/          # Interface Layer: Interfaces, Controllers, Dtos, etc
    └── test/                   # Test files

Scripts API Reference

Server

Script Description
npm run start Start server (without watch)
npm run start:dev Start development server
npm run start:debug Start debug development server
npm run start:prod Start production server

Build

Script Description
npm run build Build project

Lint & Format

Script Description
npm run format Format files with Prettier
npm run check Lint, format and apply fixes with Biome
npm run lint Lint files with Biome
npm run lint:fix Lint & fix files with Biome
npm run lint:ts Check typescript files

Misc

Script Description
npm run prepare Install Husky git hooks
make dev Build & start development server with docker
make deploy Build & start production server with docker

Resources

Check out a few resources that may come in handy when working with NestJS:

  • Visit the NestJS Documentation to learn more about the framework.
  • Deploy your application to AWS with the help of NestJS Mau in just a few clicks.
  • Visualize your application graph and interact with the NestJS application in real-time using NestJS Devtools.

One-click deploy

Deploy to Render

About

Personal NestJS Boilerplate

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published