Skip to content

ProgerDav/Nest-Boilerplate

Repository files navigation

NestJS Boilerplate Nest Logo

Start Guide

Outside Docker containers

  • Create .env file cp .env.example .env and replace existing env variables
  • Install dependencies yarn
  • Start the app yarn start (app will be exposed through the port 3000 by default)

Inside Docker containers

Just run already prepared bash script:

$ ./init

It will setup the project for you (starting docker-compose stack in development, running migrations). The NestJS app running in dev mode will be exposed on http://localhost (port 80)

TypeORM integrated

The docker-compose template uses mysql/mysql-server.

Migrations

If you don't work on a production-ready project you can always change DB_SYNC env variable to true so you can play with NestJS without the need to write actual migrations.

synchronize: true shouldn't be used in production - otherwise, you can lose production data.

Create Migration

Creating new migration is relatively easy and you can use typeorm CLI for that. You can run this command to create new migration:

$ docker exec -it nest yarn migration:create -n {CreateTableUsers}

Migration file will be placed under src/migrations. For more details check the existing 1611484925515-CreateUsersTable.ts

Run Migrations

$ docker exec -it nest yarn migration:run

Revert Migrations

$ docker exec -it nest yarn migration:revert

Test

# unit tests
$ docker exec -it nest yarn test

# e2e tests
$ docker exec -it nest yarn test:e2e

# test coverage
$ docker exec -it nest yarn test:cov

Environment Configuration

Integrated Configuration Module so you can just inject ConfigService and read all environment variables from .env file, which is created automatically by the init script from .env.example.

Swagger

Authentication - JWT

About

Convenient Starting Point

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published