Skip to content

iniva/nestjs-api-base

Repository files navigation

CI

NestJS API Base

API based on NestJS Nest Logo

Included

  • Authentication: Local and JWT strategies.
  • Database: Postgres (using TypeORM)
  • Endpoints:
    • Healthcheck
    • Users
  • Utilities:
    • Hash Manager: used for password hashing (with node:crypto)
    • Bad Request Factory: Maps ValidatorError(s) and transforms the final response payload.
  • Docker:
    • local: for development
    • test-integration: for integration tests
    • live: for deployment (dev, staging, prod, etc.)
  • CI: GitHub workflow with running tests (lint, coverage, integration).

Pre-requisites

  • Duplicate the .env.example file, rename it to .env and update the corresponding variables with valid values

Running the service locally

bash docker/local/run.sh

Testing Locally

Unit tests

# Run all unit tests
npm run test:unit

# Run specific unit test(s)
npm run test:unit -- <pattern>

# e.g.:
npm run test:unit -- file.manager

Integration tests

You need to have a valid .env file in the root of the project. The integration test suite uses this to mimic the behaviour it has during the CI runs

bash docker/test-integration/run.sh

Other Commands

Creating migrations

Try using a meaningful name for your migrations

npm run migrate:create --name=<migrationName>

# e.g.:
npm run migrate:create --name=add_upc_to_product_variants_table