Skip to content

A powerful NestJS template designed for scalable APIs with essential features like JWT authentication, multi-tenancy, Stripe payments, Swagger docs, email services, role-based access control, PostgreSQL with TypeORM, Docker support, request validation, caching, and more. Perfect for rapid development with robust architecture. πŸš€

Notifications You must be signed in to change notification settings

Code-District-Team/nestjs-template

Repository files navigation

NestJS API Template

Nest Logo

A robust NestJS-based API template with comprehensive features including:

  • πŸ” Authentication & Authorization with JWT
  • πŸ‘₯ Multi-tenant architecture
  • πŸ’³ Stripe integration for payments (API v2023-10-16)
  • πŸ“„ Swagger API documentation
  • πŸ“¨ Email service with Handlebars templates
  • 🎨 Branding customization per tenant
  • 🏒 Role-based access control (RBAC)
  • πŸ’Ύ PostgreSQL database with TypeORM
  • πŸ”„ Database migrations and seeding
  • 🎯 Request validation using class-validator
  • πŸš€ Docker support
  • πŸ“Š PDF generation
  • πŸ—ƒοΈ CSV import/export capabilities
  • ⚑ Cache manager integration
  • πŸ” Global query scopes
  • πŸ“ Comprehensive logging

Prerequisites

Make sure the following are installed on your local machine:

  1. nvm (Node Version Manager) - Install it from the official nvm repository.
  2. PostgreSQL - Version 13.x or higher Download
  3. Git - Version control system Download
  4. Docker (optional) - For containerized deployment Download

Installing Node.js with nvm

  1. Install nvm:

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash

    Or, for systems using wget:

    wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
  2. Close and reopen your terminal, or run:

    source ~/.bashrc

    (Or .zshrc, .bash_profile, depending on your shell).

  3. Install Node.js (LTS version):

    nvm install 18
  4. Set the installed version as the default:

    nvm use 18
    nvm alias default 18
  5. Verify the installation:

    node -v
    npm -v

Cloning the Repository

  1. Open your terminal or command prompt.
  2. Navigate to the directory where you want to clone the repository.
  3. Run the following command:
    git clone <repository-url>
  4. Navigate into the project directory:
    cd nestjs-template

Installing Dependencies

Run the following command in the project directory to install all required dependencies:

npm install

Setting up Environment Variables

  1. Copy the example environment file:
    cp .env.example .env
  2. Open the .env file in your preferred text editor.
  3. Update the environment variables as needed, such as database credentials, API keys, etc. Example:
    DATABASE_HOST=localhost
    DATABASE_PORT=5432
    DATABASE_USER=your_username
    DATABASE_PASSWORD=your_password
    DATABASE_NAME=your_database

Running the Application

To start the application in development mode, run:

npm run start:dev

Verify that the application is running by opening your browser and navigating to:

http://localhost:3000

Testing

Run the following commands to execute the tests:

  • Unit Tests:

    npm run test
  • End-to-End Tests:

    npm run test:e2e

Linting and Formatting

  • To lint the code, run:

    npm run lint
  • To format the code, run:

    npm run format

Useful Commands

  • Start the application in production mode:

    npm run start:prod
  • Generate a new module:

    nest generate module <module-name>
  • Generate a new controller:

    nest generate controller <controller-name>
  • Generate a new service:

    nest generate service <service-name>

Contributing

  1. Fork the repository.
  2. Create a new branch:
    git checkout -b feature/your-feature-name
  3. Commit your changes:
    git commit -m "Add your message here"
  4. Push to your branch:
    git push origin feature/your-feature-name
  5. Open a Pull Request on the main repository.

License

This project is licensed under the MIT License.

About

A powerful NestJS template designed for scalable APIs with essential features like JWT authentication, multi-tenancy, Stripe payments, Swagger docs, email services, role-based access control, PostgreSQL with TypeORM, Docker support, request validation, caching, and more. Perfect for rapid development with robust architecture. πŸš€

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •