Skip to content

Operations

The backend ships a comprehensive script surface for local development, CI, and deployment. The most important command is pnpm db:verify, which enforces the schema/type contract.

Script Purpose
pnpm lint ESLint 9 strict (@typescript-eslint/no-unsafe-*, no-floating-promises, etc.)
pnpm build nest build / tsc to dist/
pnpm test Jest unit tests (src/**/*.spec.ts) with test/kysely-stub.cjs
pnpm test:e2e Jest e2e suite (test/jest-e2e.json)
pnpm db:gen Regenerate src/db/generated.ts from live PostgreSQL
pnpm db:check Fail if generated.ts is stale
pnpm db:verify Full migration → generated.tstsc → test chain
pnpm db:smoke Run src/db/smoke.ts against the live DB
pnpm db:slice Run all live-DB slices
pnpm db:slice:<module> Run per-module slice (core, client, admin, finances, facturation, market, pressing, restaurant, salle-fete, rh, audit, uploads)
pnpm security:audit pnpm audit --prod

scripts/db-verify.mjs is the CI body:

  1. make migrate (or make reset --fresh) in ../sim-database
  2. pnpm db:gen
  3. git diff --exit-code -- src/db/generated.ts
  4. pnpm exec tsc --noEmit
  5. pnpm test
  6. pnpm db:smoke
  7. pnpm db:slice

A migration PR must ship its generated.ts diff; db:verify fails if it is stale.

  • node:22-alpine build stage
  • node:22-slim runtime stage
  • pnpm@11.9.0 with --frozen-lockfile
  • Installs postgresql-client-18 for backups
  • Installs Chromium desktop libraries for Puppeteer
  • Symlinks Chrome to /opt/chrome-bin
  • Healthcheck: wget on /api/v1/health/live

docker-compose.local.yml runs the backend and Redis. PostgreSQL is expected from ../sim-database on host.docker.internal.

Terminal window
docker compose -f docker-compose.local.yml up -d

docker-compose.dev.yml targets the VPS (dev.sim.strife-cyber.org) behind Traefik. It includes:

  • backend on internal + traefik-net
  • worker service for cron and BullMQ
  • sim-minio (renamed to avoid DNS collisions)
  • shared external Postgres

docker-compose.prod.yml includes:

  • sim-backend and redis
  • prod-network and traefik-net as external networks
  • real S3 (no in-stack MinIO)
  • Redis with REDIS_PASSWORD

src/config/db-defaults.ts is the single source of truth for PostgreSQL defaults:

export const DB_DEFAULTS = {
host: '127.0.0.1',
port: 5432,
user: 'sim',
password: 'admin',
database: 'sim_db',
poolMax: 20,
poolIdleTimeoutMs: 30000,
poolConnectionTimeoutMs: 5000,
pgAppName: 'sim-backend',
} as const;

src/config/env.validation.ts validates .env with Joi and conditionally requires secrets in production.

postgresql-client-18 is installed in the Docker image. The jobs/sauvegarde-auto.job.ts reads sauvegardes.planification and triggers SauvegardesService.declencher('AUTOMATIQUE') on schedule. There is currently no public API for backups; it is infrastructure only.

Before committing any backend change:

Terminal window
pnpm lint
pnpm build
pnpm test
pnpm db:verify

After a sim-database migration:

Terminal window
pnpm db:gen
git diff src/db/generated.ts
pnpm db:check