Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

πŸš€πŸŽ‰πŸ“š A feature-rich NestJS starter with built-in enterprise-grade architecture and popular libraries. Supports TypeScript, PostgreSQL/MySQL, TypeORM, JWT Authentication, Docker, and other essential features.

License

Notifications You must be signed in to change notification settings

netkosolution/nestjs-boilerplate

Repository files navigation

NestJS Boilerplate - Quick Start for Your API Project

A feature-rich and production-ready NestJS starter with built-in enterprise-grade architecture and popular libraries. Supports TypeScript, PostgreSQL/MySQL, TypeORM, JWT Authentication, Docker, and other essential features.

Features

  • πŸš€ Built with NestJS 10.x & Node.js 18+
  • πŸ“ TypeScript for type safety and better development experience
  • πŸ—οΈ Clean Architecture and Domain-Driven Design principles
  • πŸ” JWT Authentication & Role-based Authorization
  • πŸ” Sign in and sign up via email.
  • πŸ” Social sign in (Apple, Facebook, Google, Twitter).
  • πŸ” RBAC with custom Roles and Permissions
  • πŸ—ƒοΈ TypeORM with PostgreSQL integration
  • πŸ“Š Swagger API documentation
  • πŸ” Request validation using class-validator
  • 🎯 Unit & Integration testing setup with Jest
  • πŸ“ E2E testing with Supertest
  • πŸ”„ CI/CD pipeline with GitHub Actions
  • 🐳 Docker & Docker Compose configuration
  • πŸ“Š Winston Logger integration
  • πŸ” Error handling & logging middleware
  • πŸ“§ Mailer service integration
  • πŸ”„ Database migrations and seeders
  • πŸ“ ESLint & Prettier configuration
  • πŸ’Ύ Redis for caching
  • πŸ”„ Bull for queue management
  • πŸ“Š Health checks endpoints

Prerequisites

  • Node.js 18+
  • PostgreSQL
  • Redis
  • Docker (optional)

Getting Started

Installation

# Clone the repository
git clone https://github.com/yourusername/nestjs-boilerplate.git
# Install dependencies
npm install

Configuration

  1. Copy .env.example to .env
cp .env.example .env
  1. Update environment variables in .env file

Running the app

# Development
npm run start:dev
# Production mode
npm run start:prod
# Using Docker
docker-compose up

Running tests

# Unit tests
npm run test
# E2E tests
npm run test:e2e
# Test coverage
npm run test:cov

Project Structure

src/
β”œβ”€β”€ config/ # Configuration files
β”œβ”€β”€ core/ # Core modules, guards, decorators
β”œβ”€β”€ modules/ # Feature modules
β”‚ β”œβ”€β”€ auth/ 
β”‚ β”œβ”€β”€ users/ 
β”‚ └── ... 
β”œβ”€β”€ shared/ # Shared resources
└── main.ts # Application entry point

Auth Module

src/
└── modules/
 └── auth/
 β”œβ”€β”€ domain/ # Domain layer
 β”‚ β”œβ”€β”€ entities/ # Domain entities
 β”‚ β”œβ”€β”€ value-objects/ # Value objects
 β”‚ β”œβ”€β”€ repositories/ # Repository interfaces
 β”‚ └── services/ # Domain services
 β”‚
 β”œβ”€β”€ infrastructure/ # Infrastructure layer
 β”‚ β”œβ”€β”€ persistence/ # Database related
 β”‚ β”‚ β”œβ”€β”€ entities/ # TypeORM entities
 β”‚ β”‚ β”œβ”€β”€ repositories/ # TypeORM repositories
 β”‚ β”‚ └── migrations/ # Database migrations
 β”‚ β”œβ”€β”€ services/ # External services implementation
 β”‚ └── security/ # Security related implementations
 β”‚
 β”œβ”€β”€ interfaces/ # Interface layer
 β”‚ β”œβ”€β”€ http/ # HTTP controllers
 β”‚ β”‚ β”œβ”€β”€ controllers/
 β”‚ β”‚ β”œβ”€β”€ middlewares/
 β”‚ β”‚ β”œβ”€β”€ guards/
 β”‚ β”‚ └── dtos/
 β”‚ └── graphql/ # GraphQL resolvers (if needed)
 β”‚
 β”œβ”€β”€ services/ # Application Services
 β”‚ β”œβ”€β”€ auth.service.ts
 β”‚ └── social-auth.service.ts
 β”‚
 └── auth.module.ts # Module definition 

API Documentation

Once the application is running, you can access the Swagger documentation at:

http://localhost:3000/api/docs

Database Migrations

# Generate migration
npm run migration:generate -- src/modules/auth/infrastructure/persistence/migrations/CreateUsersTable
# Run migrations
npm run migration:run
# Revert migrations
npm run migration:revert

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you find this project useful, please give it a ⭐️ on GitHub!

Authors

  • NETKO Solution

Acknowledgments

  • NestJS Team for the amazing framework
  • The open-source community for inspiration and support

About

πŸš€πŸŽ‰πŸ“š A feature-rich NestJS starter with built-in enterprise-grade architecture and popular libraries. Supports TypeScript, PostgreSQL/MySQL, TypeORM, JWT Authentication, Docker, and other essential features.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /