CLI Reference
The @nest-extended/cli package installs the nest-cli binary for scaffolding apps and
resources.
$npm install -g @nest-extended/cli
Commands
| Command | Alias | Purpose |
|---|---|---|
nest-cli generate app <name> | g app | Scaffold a complete NestJS app |
nest-cli generate service <name> | g service | Generate a CRUD resource bundle |
nest-cli generate auth | g auth | Add an auth + users module to an app |
nest-cli migration run | m run | Run version migration scripts |
nest-cli migration events | m events | Switch controllers to the event-firing service methods |
nest-cli version | v | Print the CLI version |
generate app
nest-cli g app my-api --db PostgreSQL --orm prisma --validator zod --pm npm --auth| Flag | Alias | Values |
|---|---|---|
--database | --db | PostgreSQL, MySQL, SQLite, MongoDB |
--orm | -o | prisma, typeorm, mongoose |
--validator | -v | zod, class-validator |
--pkg-manager | --pm | npm, yarn, pnpm |
--auth | Include JWT auth + users module | |
--skip-auth | Exclude auth |
Run without flags for an interactive prompt:
nest-cli g app my-shopPrisma is pinned to v7. The generator installs
@prisma/client@^7, a driver adapter at^7, and devprisma@^7. Prisma 8 ("Prisma Next") is a different product —prisma generateandprisma db pushno longer exist and the ORM commands moved underprisma orm— and the emittedprisma-clientgenerator block, the../generated/prisma/clientimport and the driver adapters all target Prisma 7.
Scaffolded apps are emitted as CommonJS since 1.5.0.
generate service
Generates a full resource — schema/model/entity, module, service, controller, events class, DTO and specs:
nest-cli g service product
nest-cli g service qna/category # nested pathsrc/schemas/product.schema.ts
src/services/product/product.module.ts
src/services/product/product.service.ts
src/services/product/product.controller.ts
src/services/product/product.events.ts
src/services/product/dto/product.dto.ts
src/services/product/product.service.spec.ts
src/services/product/product.controller.spec.ts| Flag | Alias | Values |
|---|---|---|
--database | -d, --db | PostgreSQL, MySQL, SQLite, MongoDB |
--orm | -o | prisma, typeorm, mongoose |
--validator | -v | zod, class-validator |
--events / --skip-events | Generate {name}.events.ts — default yes | |
--broadcast / --skip-broadcast | Also broadcast events via @nestjs/event-emitter — default no |
nest-cli g service product --db MongoDB --orm mongoose -v zod --skip-events
nest-cli g service product --db MongoDB --orm mongoose -v zod --events --broadcastThe generated controller calls the event-firing methods (find, get, create,
patch, remove) and the events class is registered in the module's providers — see
Service Events. --broadcast also installs @nestjs/event-emitter
and adds EventEmitterModule.forRoot() to src/app.module.ts.
Events are wired at boot by
NestExtendedModule.forRoot(). If that is missing fromsrc/app.module.ts, the CLI warns — the generated events class would never fire.
Name transformation
| Input | Class | Variable | Folder | Route |
|---|---|---|---|---|
user-profile | UserProfile | userProfile | src/services/userProfile/ | user-profile |
qna/category | Category | category | src/services/qna/category/ | qna/category |
generate auth
Adds an Auth module (JWT + bcrypt) and a Users module to an existing app:
nest-cli g authmigration run
Rewrites imports that moved between packages — ModifyBody, User, Public and
setCreatedBy from @nest-extended/core to @nest-extended/decorators. Runs over
src/**/*.ts.
nest-cli m runmigration events
New in 1.5.0. Switches controllers from the event-free _find / _get / _create /
_patch / _remove to their event-firing counterparts, so an existing project starts
firing service events.
By default it only touches src/**/*.controller.ts — internal service-to-service calls
should keep using the underscore methods so they stay event-free.
| Flag | Purpose |
|---|---|
--dry-run | Print the changes without writing anything |
-y, --yes | Apply without the confirmation prompt |
--path <glob> | Migrate a different set of files (default src/**/*.controller.ts) |
cd my-app
nest-cli m events --dry-run src/services/company/company.controller.ts
_find -> find (line 24)
_get -> get (line 31)
...
2 file(s), 10 replacement(s).It then asks before writing. Because on* hooks are detached and cannot alter a response,
this migration does not change any endpoint's output.