Skip to content

ervikassingh/nestjs-monolithic-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NestJS Monolithic Template

Nest Logo

NestJS TypeScript

A comprehensive, production-ready NestJS monolithic template with authentication, database integration, caching, and more. Perfect for developers who want to jump-start their backend development with a well-structured, scalable foundation.

πŸš€ Features

πŸ” Authentication & Authorization

  • JWT-based authentication with Passport.js
  • Role-based access control (RBAC) with custom decorators
  • Basic authentication support
  • Guards for route protection
  • Password hashing with bcrypt

πŸ—„οΈ Database Integration

  • TypeORM for PostgreSQL with auto-loading entities
  • Mongoose for MongoDB integration
  • Database migrations and synchronization
  • Entity relationships and validation

⚑ Performance & Caching

  • Redis integration for caching and session management
  • Rate limiting with ThrottlerGuard
  • Request/Response logging with custom interceptors
  • Global exception filtering

πŸ“ API Documentation

  • Swagger/OpenAPI documentation
  • Auto-generated API docs at /api/docs
  • Bearer token authentication support
  • Request/Response schemas

πŸ› οΈ Development Tools

  • Environment-based configuration (local, dev, qa, prod)
  • ESLint and Prettier for code formatting
  • Jest testing framework with coverage
  • E2E testing setup
  • Hot reload in development mode

πŸ“ File Management

  • Static file serving for uploads
  • Image processing capabilities with Sharp
  • Multer for file uploads

πŸ“‹ Prerequisites

  • Node.js (v18 or higher)
  • PostgreSQL
  • MongoDB (optional)
  • Redis (optional)

πŸ› οΈ Installation

  1. Clone the repository

    git clone https://github.com/ervikassingh/nestjs-monolithic-template.git
    cd nestjs-monolithic-template
  2. Install dependencies

    npm install
  3. Environment Setup Create environment files based on your deployment stage:

    # Copy the example environment file
    cp .env.example .env.local

πŸš€ Quick Start

Development Mode

# Start with hot reload
npm run start:local:watch

# Start with debug mode
npm run start:local:debug

Production Mode

# Build for production
npm run build:prod

# Start production server
npm run start:prod

πŸ“š Available Scripts

Development

npm run start:local          # Start local environment
npm run start:local:watch    # Start with file watching
npm run start:local:debug    # Start with debug mode
npm run start:dev           # Start development environment
npm run start:qa            # Start QA environment

Building

npm run build:local         # Build for local environment
npm run build:dev          # Build for development
npm run build:qa           # Build for QA
npm run build:prod         # Build for production

Testing

npm run test               # Run unit tests
npm run test:watch         # Run tests in watch mode
npm run test:cov           # Run tests with coverage
npm run test:e2e           # Run end-to-end tests
npm run test:e2e:watch     # Run e2e tests in watch mode

Code Quality

npm run lint               # Run ESLint
npm run format             # Format code with Prettier

πŸ”§ Configuration

Environment Variables

The application supports multiple environment configurations:

  • local - Local development
  • dev - Development environment
  • qa - Quality assurance
  • prod - Production environment

Database Configuration

  • PostgreSQL: Primary database with TypeORM
  • MongoDB: Optional NoSQL database with Mongoose
  • Redis: Caching and session storage

Security Features

  • Rate Limiting: Configurable throttling per endpoint
  • CORS: Cross-origin resource sharing enabled
  • Validation: Request validation with class-validator
  • Exception Handling: Global exception filter

πŸ“– API Documentation

Once the application is running, visit:

  • Swagger UI: http://localhost:3000/api/docs
  • API Base URL: http://localhost:3000/api

πŸš€ Deployment

Docker (Recommended)

# Build the Docker image
docker build -t nestjs-monolithic-template .

# Run the container
docker run -p 3000:3000 nestjs-monolithic-template

Manual Deployment

  1. Build the application: npm run build:prod
  2. Set environment variables
  3. Start the application: npm run start:prod

🀝 Contributing

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

πŸ†˜ Support

πŸ™ Acknowledgments

  • NestJS - The Node.js framework
  • TypeORM - ORM for TypeScript and JavaScript
  • Mongoose - MongoDB object modeling
  • Redis - In-memory data structure store

Happy Coding! πŸŽ‰

About

A nestjs starter template with monolithic architecture.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors