Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Project Octatur Nest Logo

Description

Start Guide

Outside Docker containers

  • Create .env file cp .env.example .env and replace existing env variables (mysql/mariadb connection params)
  • Install dependencies yarn
  • Run migrations yarn migration:run
  • Start the app yarn start (app will be exposed through the port 3000)

Inside Docker containers

Just run already prepared bash script:

$ bash ./setup.sh

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

For IDE autocompletion to work, run yarn on the host machine.

TypeORM integrated

TypeORM gives you possibility to use next db types: mysql, postgres, mariadb, sqlite, etc. Please look at docs for more details. The docker-compose template uses mariadb.

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 octatur-api 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 octatur-api yarn migration:run
$ docker exec -it octatur-api yarn tenant:migration:run

Revert migrations

$ docker exec -it octatur-api yarn migration:revert

Check schema synchronization

$ docker exec -it octatur-api yarn schema:log

Reset database

$ docker exec -it octatur-api yarn db:refresh

Test configuration

Change or create a .env.test file, taking the data from the .env.example as a base, then change the NODE_ENV variable placing test and DATABASE_URL variable, placing octatur_test as the database

NODE_ENV=test
DATABASE_URL=postgres://postgres:root@postgres:5432/octatur_test
docker exec -it octatur-postgres bash -c "psql -v ON_ERROR_STOP=1 --username postgres <<-EOSQL
	CREATE DATABASE octatur_test;
EOSQL"

Test

# unit tests
$ docker exec -it octatur-api yarn test

# e2e tests
$ docker exec -it octatur-api yarn test:e2e

# test coverage
$ docker exec -it octatur-api yarn test:cov

migration all tenants

$ docker exec -it octatur-api yarn tenant:migration:run


## Rebuild container

```bash
$ docker-compose down
$ docker-compose up -d -V --build

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

RESTful APIs you can describe with already integrated Swagger. To see all available endpoints visit http://localhost:3000/api/docs

Bull Dashboard

Acesse Bull Dashboard http://localhost:3033/queue/user

Authentication - JWT

Already preconfigured JWT authentication. It's suggested to change current password hashing to something more secure. You can start use already working implementation of Login and Registration endpoints, just take a look at http://localhost:3000/api/docs.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages