Skip to content
 
 

Repository files navigation

Nest JS Project Template

Nest Logo

A modern NestJS project structure with best practices using Fastify, Prisma, MongoDB, and SWC.

Package License Node Version Pnpm Version Database

📋 Tech Stack

Features

  • Modular architecture with proper separation of concerns
  • Global exception handling and request/response transformation
  • Database integration with Prisma ORM
  • Structured logging
  • API documentation with Swagger
  • Configuration management with validation
  • Authentication and authorization
  • Unit and e2e testing setup
  • Performance optimized with Fastify and SWC

Project Structure

├── prisma/                 # Prisma ORM schema and migrations
├── src/
│   ├── config/             # Environment configuration
│   │   ├── envs/           # Environment-specific configs
│   │   └── interfaces/     # Configuration interfaces
│   ├── common/             # Global Nest modules
│   │   ├── constants/      # Constant values and enums
│   │   ├── controllers/    # Common controllers
│   │   ├── decorators/     # Custom decorators
│   │   ├── dto/            # Data Transfer Objects
│   │   ├── filters/        # Exception filters
│   │   ├── guards/         # Route guards
│   │   ├── interceptors/   # Request/response interceptors
│   │   ├── interfaces/     # TypeScript interfaces
│   │   ├── middleware/     # HTTP middleware
│   │   ├── pipes/          # Validation pipes
│   │   └── providers/      # Common providers
│   ├── core/               # Core modules (auth, database, etc.)
│   ├── modules/            # Feature modules
│   │   └── users/          # Example feature module
│   │       ├── controllers/
│   │       ├── services/
│   │       ├── dto/
│   │       └── entities/
│   ├── prisma/             # Prisma service
│   ├── shared/             # Shared modules
│   ├── app.module.ts       # Root application module
│   └── main.ts             # Application entry point
└── test/                   # End-to-end tests

Getting Started

Prerequisites

Installation

  1. Clone the repository
  2. Install dependencies:
pnpm install
  1. Set up environment variables:
cp .env.sample .env
# Edit .env with your configuration
  1. Generate Prisma client:
pnpm prisma:generate
  1. Seed the database (optional):
pnpm db:seed

Running the Application

Development mode:

pnpm start:dev

Production mode:

pnpm build
pnpm start:prod

🧹 Code Quality

Linting code:

# Check for ESLint errors
pnpm lint:check

# Fix ESLint errors automatically
pnpm lint

Note: ESLint configuration is inspired by brocoders/nestjs-boilerplate

Formatting code:

pnpm format

Testing

Running unit tests:

pnpm test

Running e2e tests:

pnpm test:e2e

API Documentation

API documentation is available at /docs when the application is running. It provides an interactive interface to explore and test the API endpoints.

License

MIT

About

NestJS project template. Auth, Prisma, MongoDB, Pino, Docker.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages