Skip to main content

Development Server

Start the application in watch mode for automatic reloading on file changes:
npm run start:dev
The server runs on port 3001 by default. The application uses SWC as the TypeScript compiler for faster builds.

Docker Compose Environment

The project includes a full Docker Compose setup for local development:
# Start all services
npm run dev

# Rebuild containers
npm run dev:build

Services

ServicePortDescription
App30011NestJS application
PostgreSQL54321Primary database
Redis63791Cache and sessions
Elasticsearch9200Customer search
Migrator-Runs DB migrations on startup

Testing

The project uses Jest with ts-jest for testing.
# Run all tests
npm test

# Watch mode
npm run test:watch

# Coverage report
npm run test:coverage-report

# End-to-end tests
npm run test:e2e

# Debug mode
npm run test:debug

Test Utilities

  • jest-mock-extended for type-safe mocking
  • jest-when for conditional mock returns
  • supertest for HTTP integration testing
  • MockDate for time-dependent tests

Test Structure

Tests live in __test__ directories adjacent to source files:
src/reactivate/campaigns/
├── campaign.controller.ts
├── campaign.service.ts
└── __test__/
    ├── campaign.controller.spec.ts
    └── campaign.service.spec.ts

Debugging

VS Code Debugger

Start the application in debug mode:
npm run start:debug
This opens a debugger on port 9229. Attach VS Code using the Node.js debugger.

Logging

The application uses Pino (via nestjs-pino) for structured logging.
VariableOptionsDefault
LOG_LEVELtrace, debug, info, warn, errordebug
LOG_PRETTYtrue, falsetrue
USE_NEST_LOGGERtrue, falsefalse

Database Migrations

Create a new migration

npm run typeorm:generate-migration -- -n MigrationName

Run migrations

npm run typeorm:run-migrations

Revert last migration

npm run typeorm:revert-migration

Code Style

  • TypeScript strict mode
  • NestJS conventions (modules, controllers, services, guards)
  • Use Case pattern for business logic
  • Class-validator for DTO validation
  • Zod for runtime schema validation