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.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.