Getting Started

This is a boilerplate for clean architecture in NodeJS using Typescript.

The project consist of a simple database implementation with an office acting as main table and an user linked to it.

Following the next instruction we will be able to run it on you local machien.

Tools

The following tools should be installed in your machine:

To avoid conflicts, please use the following versions of node and yarn:

  • Node: 12.13.1
  • Yarn: 1.22.5

If you have a different node version you can follow the next steps to upgrade or downgrade it:

  • sudo yarn global add n
  • sudo n 12.13.1

Bulding

  • yarn install
  • yarn dev

Note that the command dev will run a docker-compose which contains mysql and mysql adminer, so you don't need any of these in your machine.

Database

Note that is pretty simple to use any other SQL database. If you want to do that we you will need to change docker compose and also change the database dialect in sequelize configuration.

To create a new database you just have to run yarn create-database. By default an user will be createrd with both username and password "test".

To use migrations you can run any of the following steps:

  • yarn sequelize migration:create --name= (will create new migration file)
  • yarn migrates ou yarn sequelize db:migrate (will run all migrations)
  • yarn undo-migrates ou yarn sequelize db:migrate:undo (will undo all migrations)
  • yarn sequelize seed:generate --name (will create a new seeder)
  • yarn sequelize-cli db:seed: (will run only one seeder)
  • yarn sequelize-cli db:seed:all (will run all seeders)
  • yarn sequelize-cli db:seed:undo --seed (will undo one seeder)
  • yarn sequelize-cli db:seed:undo:all (will undo all seeders)

Tests

To test, just use any of the following commands:

  • yarn test (will run all tests)
  • yarn unit-test (will run all unit tests)
  • yarn one-unit-test (will run only one unit test)
  • yarn integration-test (will run all integration tests)
  • yarn one-integration-test (will run only one integration test)

Contributing

This project is just a basic init for any project using NodeJs. It still need some improvements such as:

  • Create GitHub Actions based in the GitLab Pipelines which can be found in the file .gitlab-ci.yaml
  • Fix an husky error when building the image using Dockerfile

So you you are interested just see the CONTRIBUTING.md