Skip to content

nati-m-afw/nestjs-boilerplate

Repository files navigation


NestJS API Boilerplate


Modern NestJS API Boilerplate

A production-ready NestJS API boilerplate with TypeORM, Redis, PostgreSQL, and Docker support. Based on nestjs-starter-rest-api by Monstar Lab.

Features

  • 🚀 NestJS Framework
  • 🔐 JWT Authentication
  • 🎯 TypeORM with PostgreSQL
  • 📝 Swagger API Documentation
  • 🐳 Docker & Docker Compose
  • 🔄 Redis as a message queue
  • 🔍 E2E Testing Setup
  • 🛡️ Role-Based Access Control (RBAC)
  • 🔄 Database Migrations & Seeding
  • 🌐 NGINX Reverse Proxy

Prerequisites

  • Docker & Docker Compose
  • Node.js 16+
  • Yarn package manager

Getting Started

  1. Clone the repository
  2. Create environment variables file:
cp .env.example .env
  1. Configure Redis (required for queue system):
./queue/prod-conf/init-redis.sh
  1. Start the development environment:
make up

Development Commands

Container Management

# Start services
make up

# View logs
make logs

# Stop services
make down

# Rebuild services
make build

Database Operations

# Run migrations
make dc exec app yarn migration:run

# Seed database with initial data
make dc exec app yarn migration:seed

# Generate new migration
make dc exec app yarn migration:generate --name=MigrationName

Code Generation

# Generate new NestJS module
make api-gen

Project Structure

.
├── apps/api/          # NestJS application
│   ├── src/          # Source code
│   ├── test/         # E2E tests
│   └── migrations/   # Database migrations
├── proxy/            # NGINX configuration
├── queue/            # Redis configuration
└── docker-compose.yml

Available Services

  • API: NestJS application (default: port 5969)
  • PostgreSQL: Database server
  • Redis: Caching and queue management
  • NGINX: Reverse proxy

Documentation

API Documentation

API documentation is available at /docs endpoint when the server is running.

Project Documentation

Detailed documentation is available in the docs/ directory:

  • Architecture Guide: Comprehensive overview of the module structure, including:

    • Module components and layers
    • Security features
    • Best practices
    • Common design patterns
  • Makefile Guide: Documentation for all available make commands and environment configurations:

    • Available commands and their usage
    • Environment configuration options
    • Customization guidelines
    • Docker Compose service management

For architecture details, see docs/architecture.md For build and deployment commands, see docs/makefile.md

Testing

# Run e2e tests
make dc exec app yarn test:e2e

For more commands, run:

make help

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published