Imported from diego10j/nest-core-api (
AGENTS.md). Install upstream withnpx skills add diego10j/nest-core-api. Copyright stays with the author.
AGENTS.md
Project Overview
NestJS backend API for Pro-ERP. Single package, src/ is source root.
Dev Commands
yarn start:dev— watch mode with hot reloadyarn build— production build (output todist/)yarn start:prod— run built image via pm2yarn lint— ESLint with unused-imports plugin (also enforces import order)yarn test— Jest unit tests (root insrc/, pattern*.spec.ts)yarn test:e2e— e2e tests (test/jest-e2e.json)yarn format— Prettier onsrc/andtest/
Test Commands
- Single test file:
yarn test -- <file-match> - Single test:
yarn test -- --testPathPattern=<name> - Coverage:
yarn test:cov
Dependencies & Services
- PostgreSQL via Docker Compose (port 5432, config in
docker-compose.yaml) - Redis — ioredis, configured via env vars
- Start DB:
docker-compose up -d
Runtime Configuration
- API prefix:
/api - Swagger docs:
/docs(antes/doc) - WebSocket (Socket.IO): port 3001
- CORS whitelist: localhost:18080, 192.168.56.103:18080, devproerpec.site, proerp.sigafi.com
- Multi-tenancy headers:
X-Ide-Usua,X-Ide-Empr,X-Ide-Sucu,X-Ide-Perf,X-Login,X-Ip,X-Terminal - Rate limiting: 300 req/min per IP (ThrottlerModule)
Build & Deploy
- Production:
pm2 start npm --name "nest-core-api" -- run start:prod(viadeploy.sh) generated/anddist/are excluded from linting
Architecture
- Entry:
src/main.ts - Root module:
src/app.module.ts - Feature modules under
src/core/modules/ src/core/contains auth, db connection, email, whatsapp, and business modulessrc/reports/— PDF generation (pdfmake, printer service)src/config/envs.ts— env configuration loader
Lint Rules
- Unused imports are errors (
unused-imports/no-unused-imports) - Import order: builtin → external → internal (
@/**) → parent → sibling - Vars/args prefixed with
_are ignored
Database
- Scripts in
scripts/(.sqlfiles for schema/triggers) - Uses DataSource Native Querys(
src/core/connection/datasource.module.ts)
Environment
- Copy
.env.template→.envbefore starting - JWT secrets required (access + refresh, different secrets)
PATH_DRIVEfor local file storage
FK Null Handling
- Use
?? nullfor optional FK fields (e.g.,dtoIn.ide_vgtra ?? null) - NEVER use
|| null—0is a valid number,||would coerce it tonullincorrectly - If frontend sends
ide_xxx: 0for a FK that doesn't exist, let the DB FK constraint fail — don't silently convert to null