- NestJS - A progressive Node.js framework for building efficient, reliable and scalable server-side applications.
- Prisma - Next-generation Node.js and TypeScript ORM.
- Jest - Delightful JavaScript Testing Framework with a focus on simplicity.
- Husky - Git hooks made easy dog woof!
- ESLint - Find and fix problems in your JavaScript code.
- Prettier - An opinionated code formatter.
- Lint Staged - Run linters on git staged files.
- CommitLint - Lint commit messages.
- Volta* (node, npm, and yarn version manager)
Install the following dependencies:
- Docker Desktop (An one-click-install application that enables you to build and share containerized applications and microservices.)
- Docker Compose (Plugin for running multi-container Docker applications)
Then create a docker.env
file with the following values:
MYSQL_ALLOW_EMPTY_PASSWORD=yes
MYSQL_USER=my_user
MYSQL_PASSWORD=my_secret_passwd
MYSQL_ROOT_PASSWORD=my_ultra_secret_passwd
MYSQL_DATABASE=my_db_name
Create a copy of .env.example
with the name .env
and .env.test.example
with the name .env.test
and placed it at the root of the project
cp .env.example .env
cp .env.test.example .env.test
Replace its values with your own credentials.
Run the following commands to install all dependencies:
volta install node
volta install yarn
yarn
Run the following commands to create and populate the databases:
yarn prisma:migrate:run
yarn prisma:migrate:run:test
yarn prisma:generate
yarn prisma:seed
Run yarn start:dev
to start a development server that watch for changes. For a debug server use: yarn start:debug
Always run yarn prisma:generate
after any change to scheme.prisma
.
Run yarn test
to execute the unit tests via Jest. For coverage test use: yarn test:cov
Run yarn build
to compile for production, this will execute prebuild
and postbuild
commands automatically. Then run yarn start:prod
to start a production server.
Script | Description |
---|---|
yarn start |
Start server (without watch) |
yarn start:dev |
Start development server |
yarn start:debug |
Start debug development server |
yarn start:prod |
Start production server |
yarn pm2 |
Run production server as Cluster with PM2 |
yarn pm2:restart |
Reload API with PM2 |
yarn pm2:stop |
Stop PM2 service |
yarn pm2:logs |
View PM2 logs |
Script | Description |
---|---|
yarn prebuild |
Clean dist folder |
yarn build |
Build project |
Script | Description |
---|---|
yarn format |
Format files with Prettier |
yarn lint |
Lint files with ESLint |
Script | Description |
---|---|
yarn test |
Run test (without watch) |
yarn test:watch |
Run test and watch |
yarn test:cov |
Run coverage test |
yarn test:e2e |
Run end-to-end tests |
yarn test:debug |
Debug tests |
Script | Description |
---|---|
yarn prisma:migrate:save |
Creates a new migration based on the changes in the schema but does not apply that migration. |
yarn prisma:migrate:run |
Applies all pending migrations, and creates the database if it does not exist. |
yarn prisma:migrate:run:test |
Run migrations for test |
yarn prisma:migrate:reset |
Reset development DB |
yarn prisma:migrate:reset:test |
Reset test DB |
yarn prisma:generate |
Generate Prisma Client (artifacts) |
yarn prisma:seed |
Polulate DB with seed data |
yarn prisma:format |
Format your schema |
For more information on Prisma, read the official documentation
Script | Description |
---|---|
docker-compose up -d |
Builds, (re)creates, starts, and attaches to containers for a service. |