API Application

API uses NestJS. Please refer to the NestJS documentation for more information.

Environment variables

Environments variables should be in .env file. Any change in this file should be reflected in GitHub Secrets and variables, in the secret API_DEV_VARS API_PROD_VARS or API_DEV_SECRETS API_PROD_SECRETS depending on the environment.

Using CLI

Generating different artifacts with NestJS CLI

Example :
# Generate a resource (CRUD module with everything included)
pnpm dlx @nestjs/cli g resource

# Generate a module
pnpm dlx @nestjs/cli g module MODULE_NAME

# Generate a controller
pnpm dlx @nestjs/cli g controller CONTROLLER_NAME

# Generate a service/provider
pnpm dlx @nestjs/cli g service SERVICE_NAME

# Check the help for more options
pnpm dlx @nestjs/cli generate --help

Migrations

Generate a migration:

Example :
npm run migrate:generate --migration_name=[MigrationName]

Create empty migration:

Example :
npm run migrate:create --migration_name=[MigrationName]

Run migrations:

Example :
npm run migrate:run

Revert migrations:

Example :
npm run migrate:revert

Deployment

The API is deployed in GCP CloudRun. The deployment is done automatically by GitHub Actions using Dockerfile.api and follows the next logic:

  • If we push to master branch, deploy-to-dev.yml workflow will deploy to dev environment.
  • If we push to production branch, deploy-to-prod.yml workflow will deploy to prod environment.

Setup Connection to GCP Cloud SQL From Cloud Run:

Authenticate GCP to be able to use BigQuery:

  • gcloud auth application-default login

results matching ""

    No results matching ""