Skip to content

Nest.js 10 boilerplate Docker-Compose, ESLint, Husky, Lint-staged, OpenAPI, Prettier, PostgreSQL, TypeORM

Notifications You must be signed in to change notification settings

ahelord/nest-boilerplate

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nest logo TypeORM logo PostgreSQL logo Jest logo Prettier logo ESLint logo

Docker logo GitHub Actions logo

Nest 10.x - Boilerplate

Commitizen friendly code style: prettier Conventional Commits GitHub issues GitHub pull requests GitHub stars GitHub forks GitHub contributors GitHub license GitHub code size in bytes GitHub repo size

Table of contents


Getting started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

What things you need to install the software and how to install them :


Installation

  1. Clone the git repository

    git clone https://github.com/ahelord/nest-boilerplate.git
  2. Go into the project directory

    cd nest-boilerplate/
  3. Install NPM dependencies

    npm i

Run locally

  1. Copy .env-local to .env

    cp .env-local .env
  2. Replace the values of the variables with your own

  3. Start

    npm run start:dev

Run docker

  1. Copy .env-docker to .env

    cp .env-docker .env
  2. Replace the values of the variables with your own

  3. Create Docker images and launch them

    docker-compose up -d --build

What's in the box ?

Commitizen

commitizen is a command line utility that makes it easier to create commit messages following the conventional commit format specification.

Use git cz instead of git commit to use commitizen.

Add and commit with Commitizen

Configuration file: .czrc.


Commitlint

commitlint checks if your commit messages meet the conventional commit format.

Configuration file: .commitlintrc.json.

In general the pattern mostly looks like this:

type(scope?): subject  #scope is optional

Are you a good commitizen ?


Docker Compose

Compose file: docker-compose.yml.

Containers :

  • PostgreSQL 16.1
  • pgAdmin 4:8.3

Compose file uses .env.


ESLint

ESLint is a fully pluggable tool for identifying and reporting on patterns in JavaScript.

Configuration file: .eslintrc.js.

For more configuration options and details, see the configuration docs.


Husky

Husky is a package that helps you create Git hooks easily.

Configuration folder: .husky.


Lint-staged

Lint-staged is a Node.js script that allows you to run arbitrary scripts against currently staged files.

Configuration file: .lintstagedrc.json.


Prettier

Prettier is an opinionated code formatter.

Configuration file: .prettierrc.
Ignore file: .prettierignore.

For more configuration options and details, see the configuration docs.


Running the app

development

npm run start

watch mode

npm run start:dev

production mode

npm run start:prod

Code scaffolding

Run nest generate|g <schematic> <name> [options] to generate a new Nest Element.


Build

Run npm run build to build the project. The build artifacts will be stored in the dist/ directory.


Test

unit tests

npm run test

e2e tests

npm run test:e2e

test coverage

npm run test:cov

Further help

To get more help on the Nest CLI use nest --help or go check out the Nest CLI README.


Useful Docker commands

  1. If you want to check that all containers are up :

    docker-compose ps
  2. Other Docker commands :

    # Start Docker
    docker-compose start
    
    # Restart Docker
    docker-compose restart
    
    # Stop Docker
    docker-compose stop
    
    # Delete all containers
    docker rm $(docker ps -aq)
    
    # Delete all images
    docker rmi $(docker images -q)
  3. How to get a Docker container's IP address from the host ?

    docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container>
    docker inspect $(docker ps -f name=<service> -q) | grep IPAddress

Typeorm migrations

  1. Windows
    # Create empty migration windows
     npm run typeorm:migration:create:win --name=createPerson
    
    # Generate migrations from entities empty migration
     npm run typeorm:migration:generate:win --name=initMigration
    
  2. Unix
    # Create empty migration
     npm run typeorm:migration:create:unix --name=createPerson
    
    # Generate migrations from entities empty migration
     npm run typeorm:migration:generate:unix --name=initMigration
    
  3. Run migrations and revert
    # Run pending migrations
     npm run typeorm:migration:run
    
    # Revert migrations
     npm run typeorm:migration:revert 
    

About

Nest.js 10 boilerplate Docker-Compose, ESLint, Husky, Lint-staged, OpenAPI, Prettier, PostgreSQL, TypeORM

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 93.4%
  • JavaScript 3.9%
  • Shell 1.4%
  • Dockerfile 1.3%