Skip to content

echandsome/nest-xlr8

Repository files navigation

Nest XLR8 - Scalable NestJS Application

A production-ready NestJS application with authentication, user management, and comprehensive testing. Built with clean architecture principles, security best practices, and scalability in mind.

🚀 Features

  • Authentication & Authorization: JWT-based authentication with secure password hashing
  • User Management: Complete CRUD operations for user management
  • Database Integration: Mongoose ODM with MongoDB support
  • Background Jobs: Redis-based job queue system for asynchronous processing
  • API Documentation: Swagger/OpenAPI documentation
  • Security: Helmet, CORS, rate limiting, input validation
  • Testing: Unit tests, integration tests, and e2e tests
  • Logging: Comprehensive request/response logging
  • Error Handling: Global exception handling with proper error responses
  • Validation: Input validation with class-validator
  • TypeScript: Full TypeScript support with strict typing

📋 Prerequisites

  • Node.js (v18 or higher)
  • MongoDB (v4.4 or higher)
  • Redis (v6.0 or higher)
  • npm or yarn

🛠️ Installation

  1. Clone the repository

    git clone https://github.com/echandsome/nest-xlr8
    cd nest-xlr8
  2. Install dependencies

    npm install
  3. Set up environment variables

    cp env.example .env

    Update the .env file with your configuration:

    # Database
    DATABASE_URL="mongodb://localhost:27017/nest-xlr8"
    
    # JWT
    JWT_SECRET="your-super-secret-jwt-key-change-this-in-production"
    JWT_EXPIRES_IN="1h"
    
    # Server
    PORT=3000
    NODE_ENV="development"
    
    # CORS
    CORS_ORIGIN="http://localhost:3000"
    
    # Rate Limiting
    RATE_LIMIT_TTL=60
    RATE_LIMIT_LIMIT=100
    
    # Global Prefix
    GLOBAL_PREFIX="api/v1"
    
    # Logging
    LOG_LEVEL="info"
    LOG_DIR="src/logs"
    LOG_MAX_FILES=5
    LOG_MAX_SIZE="20m"
    
    # Redis
    REDIS_HOST="localhost"
    REDIS_PORT=6379
    REDIS_PASSWORD=""
    REDIS_DB=0
    REDIS_URL="redis://localhost:6379/0"
  4. Set up the databases

    # Make sure MongoDB is running on your system
    # The application will automatically connect to MongoDB using the DATABASE_URL
    
    # Make sure Redis is running on your system
    # The application will automatically connect to Redis using the REDIS_URL

🚀 Running the Application

Development

npm run start:dev

Production

npm run build
npm run start:prod

Debug Mode

npm run start:debug

🧪 Testing

Unit Tests

npm run test

E2E Tests

npm run test:e2e

Test Coverage

npm run test:cov

Watch Mode

npm run test:watch

📚 API Documentation

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

🔧 Available Scripts

  • npm run build - Build the application
  • npm run start - Start the application
  • npm run start:dev - Start in development mode with hot reload
  • npm run start:debug - Start in debug mode
  • npm run start:prod - Start in production mode
  • npm run lint - Run ESLint
  • npm run format - Format code with Prettier
  • npm run test - Run unit tests
  • npm run test:watch - Run tests in watch mode
  • npm run test:debug - Run tests in debug mode
  • npm run test:cov - Run tests with coverage
  • npm run test:e2e - Run e2e tests

About

Production-ready NestJS boilerplate with JWT auth, MongoDB (Mongoose), Redis job queues, Swagger docs, and full testing setup

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors