Patch notes
Changelog of notable CLI, template, and workflow changes in Koala Nest.Changelog for anyone using or upgrading CLI-generated projects. Deep dives live on the linked documentation pages.
The published @koalarx/nest version is shown on the site and in the repo package.json. Root CHANGELOG.md mirrors these notes.
4.4.0 — Build, Docker, QueueBase, Helmet, and Worker
What changed
tsc-aliasin build: generated projects usenest build && tsc-alias -p tsconfig.build.jsonso@/*imports work indist/(production/Docker).- Dockerfile per package manager:
kl-nest newwritesDockerfile+entrypoint.shforbun,npm, orpnpm. - Queue jobs (opt-in):
kl-nest new/kl-nest add queuecopiesQueueBase,IQueueService, stubQueueService, and a test fake; injects abstract env vars (QUEUE_MAX_CONCURRENCY, delays).QueueBasereads concurrency/delays viaEnvService(do not pass them in the constructor). No broker SDK — implement infra later. - Helmet in core:
applyHttpMiddlewaresets security headers (CSP tuned for Scalar/cdn.jsdelivr.net, HSTS only inproduction), following the Globo Seguros pattern. - Security docs: new Security topic (PT/EN) with a layered view (Helmet, CORS, rate limit, cookies, validation, auth, RedLock).
refreshTokencookie: on login,SameSite/SecurefollowAPI_HOST— localhost usesStrictwithoutSecure; otherwiseNone+Securefor cross-site XHR.- App type (API vs Worker):
kl-nest newasks for the type (or--type/--app-type). API keeps HTTP + OpenAPI. Worker (broker / queue / background) usesNestFactory.createApplicationContext— no listen, Helmet, CORS, Scalar, PORT/HOST, controllers, decorators, or filters; Dockerfile withoutEXPOSE 3000. Prefer--features queue,cron,events. Queue alone does not installhost/jobs/JobsModule(only cron/events). Incompatible with CRUD template, HTTP auth, and health. Full guide (prompts + silent-ymode): Installation guide. .gitignorein scaffold:kl-nest newalways copies the template.gitignore(npm packomitted files named.gitignore; the build also publishesgitignore).- AI context docs: new AI context topic (PT/EN) — purpose, Cursor/Copilot,
kl-nest add ai-context, and recommended layout (.github/instructions,agents,prompts,skills).
Upgrade
On existing projects: update the build script and add tsc-alias as a devDependency; copy a Dockerfile matching your PM if you containerize; use kl-nest add queue for messaging; install helmet and align apply-http-middleware.ts with the current template; align refreshToken cookie options in login.controller.ts with the current template. For a new worker/broker: kl-nest new my-worker -y --type worker --features queue.
4.3.1 — OpenAPI scaffold and tsconfig
What changed
- Scalar
hiddenClients: removed invalid IDs (request,http1,http2,httr) that caused TypeScript errors in generateddefine-documentation.ts. - Sync OpenAPI slim variants: no-auth and JWT-only templates no longer use
asyncwithoutawait(avoids@typescript-eslint/require-await). tsconfig.spec.jsonin scaffold: copied/generated with core (Bun: template withbun-types+@types/bun; npm/pnpm: minimal variant) so ESLint finds the file referenced inparserOptions.project.
Upgrade
On existing projects: align the hiddenClients list and drop unnecessary async in OpenAPI to match the current template; if ESLint points at a missing tsconfig.spec.json, copy it from the template (or the npm/pnpm variant) and, on Bun, add @types/bun as a devDependency.
4.3.0 — API Key (M2M auth)
What changed
- New additive
api-keystrategy: use with JWT and/or OAuth2 (--auth jwt,api-key). Cannot be selected alone. - CRUD
/api-key: issues a long-lived RS256 JWT (typ: api-key) and validates origin (domain/host/uri). - Optional internal subnet:
--api-key-internal-subnet(or CLI prompt) allows private IPs for pod-to-pod traffic ondomaintype. - Scalar:
ApiKeyheader scheme alongside JWT/OAuth2. - Auth docs cover M2M edge auth without replacing broker/storage.
- AI context (vibecoding): in
kl-nest new(prompt) andkl-nest add ai-context cursor|github— scaffoldsAGENTS.mdplus Cursor rules / Copilot instructions for the generated project (docs-first + DDD constraints). Skipped with-y; useaddafterwards. Does not overwrite existing files. - JWT keys in
.env: when choosing JWT, OAuth2 and/or API Key inneworadd auth, the CLI generates an RS256 key pair (JWT_PRIVATE_KEY/JWT_PUBLIC_KEYas base64) and fills.env..env.examplekeeps empty placeholders; existing values are not overwritten.
Upgrade
On existing projects: kl-nest add auth api-key (with JWT/OAuth2 already installed), optionally --api-key-internal-subnet. Apply the CreateApiKey migration and add passport-custom if needed.
For AI context on existing projects: kl-nest add ai-context cursor, github, or both.
4.2.0 — Migrations and entity discovery
What changed
- CLI entities:
migration-datasource.tsno longer uses a filesystem glob; it readsDbContext.entities, populated byload-all-entities.tswhen generating/running migrations outside Nest. Entity load failures propagate (only a missing entities directoryENOENTis ignored). - API boot:
dataSourceFactoryconfigures themigrationsarray and callsrunMigrations()afterinitialize()— pending migrations apply on startup. - npm/pnpm scripts: migrations use
ts-node+tsconfig-pathsso@/aliases resolve.dotenv,ts-node, andtsconfig-pathsare part of the CLI core packages. - Auth: auth install no longer patches
data-source-factory.ts. Entities (e.g.User) register inDbContextvia repository imports. @koalarx/utilsprototypes: the template enablesimport '@koalarx/utils/prototypes'insrc/host/main.tsand test setups. On the Nest backend, the default style is native methods (e.g..maskCpf(),.orderBy());delay,randomString, and holidays remain explicit imports. See Koala Utils.- Checklist / boot:
load-all-entities.tsand the other migration files are required by project validation;main.tsmust import@koalarx/utils/prototypes.
How it works (short guide)
- Entities under
src/domain/entities/use@Entityfrom@/core/database/entity(registers inDbContext). - At runtime, Nest imports repositories → loads entities →
dataSourceFactoryusesDbContext. - In the CLI (
migration:generate/migration:run),load-all-entitiesrequires entity files (skipping enums) to fill the sameDbContext. - On API start, pending migrations run automatically.
migration:runremains available for CI/ops.
Full guide: Migrations · Database
Existing projects (upgrade)
If the project was generated from an older template:
- Copy/adapt
src/infra/database/migrations/load-all-entities.tsfrom the current template. - In
migration-datasource.ts, import./load-all-entitiesand useentities: Array.from(DbContext.entities.values()). - In
data-source-factory.ts, add themigrationsglob +await dataSource.runMigrations(). - Remove manual
entities: [Person, ...]lists (or any patch that keeps them). - For npm/pnpm, ensure
dotenv,ts-node, andtsconfig-paths, with scripts using--require tsconfig-paths/register. - In
src/host/main.ts(and test setups), import@koalarx/utils/prototypes.
There is no compatibility layer in the CLI: the new template is the source of truth.