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.
npm / pnpm scripts
Section titled “npm / pnpm scripts”| 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.ts → tsc → 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 |
db:verify
Section titled “db:verify”scripts/db-verify.mjs is the CI body:
make migrate(ormake reset --fresh) in../sim-databasepnpm db:gengit diff --exit-code -- src/db/generated.tspnpm exec tsc --noEmitpnpm testpnpm db:smokepnpm db:slice
A migration PR must ship its generated.ts diff; db:verify fails if it is stale.
Docker
Section titled “Docker”Dockerfile
Section titled “Dockerfile”node:22-alpinebuild stagenode:22-slimruntime stagepnpm@11.9.0with--frozen-lockfile- Installs
postgresql-client-18for backups - Installs Chromium desktop libraries for Puppeteer
- Symlinks Chrome to
/opt/chrome-bin - Healthcheck:
wgeton/api/v1/health/live
Local compose
Section titled “Local compose”docker-compose.local.yml runs the backend and Redis. PostgreSQL is expected from ../sim-database on host.docker.internal.
docker compose -f docker-compose.local.yml up -dDevelopment compose
Section titled “Development compose”docker-compose.dev.yml targets the VPS (dev.sim.strife-cyber.org) behind Traefik. It includes:
backendoninternal+traefik-networkerservice for cron and BullMQsim-minio(renamed to avoid DNS collisions)- shared external Postgres
Production compose
Section titled “Production compose”docker-compose.prod.yml includes:
sim-backendandredisprod-networkandtraefik-netas external networks- real S3 (no in-stack MinIO)
- Redis with
REDIS_PASSWORD
Environment defaults
Section titled “Environment defaults”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.
Backups
Section titled “Backups”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.
Verification checklist
Section titled “Verification checklist”Before committing any backend change:
pnpm lintpnpm buildpnpm testpnpm db:verifyAfter a sim-database migration:
pnpm db:gengit diff src/db/generated.tspnpm db:check