项目作者: smarlhens

项目描述 :
Nest.js boilerplate with CircleCI, Commitizen, Commitlint, Docker-Compose, ESLint, GitHub Actions, Husky, Lint-staged, OpenAPI, Prettier, PostGreSQL, Travis CI, TypeORM
高级语言: TypeScript
项目地址: git://github.com/smarlhens/nest-boilerplate.git
创建时间: 2020-04-04T20:40:52Z
项目社区:https://github.com/smarlhens/nest-boilerplate

开源协议:

下载



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


Docker logo
GitHub Actions logo
CircleCI logo

Nest - Boilerplate

GitHub CI
CircleCI
Commitizen friendly
code style: prettier
Conventional Commits

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

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

    1. cd nest-boilerplate/
  3. Checkout working branch

    1. git checkout <branch>
  4. Install NPM dependencies

    1. npm i
  5. Copy .env.dist to .env

    1. cp .env.dist .env
  6. Replace the values of the variables with your own

  7. Create Docker images and launch them

    1. docker-compose up -d --build

What’s in the box ?

CircleCI

CircleCI automates your software builds, tests, and deployments.

CircleCI pipeline file: .circleci/config.yml.

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


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:

  1. type(scope?): subject #scope is optional

Are you a good commitizen ?


Docker Compose

Compose file: docker-compose.yml.

Containers :

  • PostgreSQL 14
  • pgAdmin 6

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.


GitHub Actions

GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.

CI workflow file: .github/workflows/ci.yml.


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.json.
Ignore file: .prettierignore.

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


Running the app

development

  1. npm run start

watch mode

  1. npm run start:dev

production mode

  1. 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

  1. npm run test

e2e tests

  1. npm run test:e2e

test coverage

  1. 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 :

    1. docker-compose ps
  2. Other Docker commands :

    1. # Start Docker
    2. docker-compose start
    3. # Restart Docker
    4. docker-compose restart
    5. # Stop Docker
    6. docker-compose stop
    7. # Delete all containers
    8. docker rm $(docker ps -aq)
    9. # Delete all images
    10. docker rmi $(docker images -q)
  3. How to get a Docker container’s IP address from the host ?

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