Setup NestJS App

This documentation was generated with the assistance of AI. Please report any inaccuracies.

Scaffolds a NestJS 12 service with the Nest CLI, or brings an existing NestJS app up to date, and layers this catalog’s toolchain and a small, tested application skeleton on top.

Purpose

iru-setup-nestjs-app generates the app in a temporary directory (the Nest schematics refuse to write next to existing files) and copies it into the repository without overwriting anything. It uses nest new for ESM with Vitest (the default) or the application schematic with --type=cjs for CommonJS with Jest. It then post-processes it:

  • package.json with version 0.1.0-dev.0, private: true, and the shared script names iru-setup-typescript-github-workflows and the iru-typescript-* gate skills detect: lint (Oxlint type-aware), format/format:check (Prettier), typecheck, test, coverage (80% threshold, lcov at coverage/lcov.info), test:e2e, build, start, docs (Compodoc or TypeDoc).

  • A skeleton that is the first exemplar of the iru-nestjs-code-one-task conventions: ConfigModule validated by a Zod schema, a global ValidationPipe as APP_PIPE, a shared configureApp() used by both main.ts and the e2e tests, @nestjs/terminus liveness and readiness endpoints, and a tested sample books feature module (only added to an existing app on request).

  • Optional persistence (orm: TypeORM, Prisma 7, Mongoose 9 or Drizzle) with migrations and Testcontainers-backed e2e tests.

  • A multi-stage non-root Dockerfile with a health check and .env.example (always written), and sonar-project.properties when Sonar is enabled.

Versions are resolved live from npm with verified fallbacks. The skill announces whether it is scaffolding from scratch or updating an existing app and, per owned artifact that already exists, asks Update / Keep as is / Replace (or Stop) unless on-existing pre-answers; application source such as main.ts is recommended as Keep.

Plugin

Shipped by the iru-nestjs plugin of the ai-catalog marketplace (install with /plugin install iru-nestjs@ai-catalog; see Plugins).

Invocation

/iru-setup-nestjs-app

When called from iru-setup-typescript-repository, the resolved answers arrive as args key: value lines.

Inputs

Argument Required Description Default

app-name, description

No

package.json name (lowercase kebab-case, also the image name) and description.

Repository directory name; asked

license, developer-name, developer-email, organization-url

No

package.json license and author.

Asked (existing apps: read from package.json)

open-source, visibility, ci

No

Shared pipeline vocabulary; visibility and ci only drive the Sonar recommendation.

Asked or derived (gh repo view)

sonar (+ sonar-organization, sonar-project-key, sonar-host-url)

No

cloud, self-hosted or none; writes sonar-project.properties unless none.

Asked; none recommended for private repositories

module-system

No

esm (Vitest) or cjs (Jest). Fixed by an existing app’s type.

esm

http

No

express or fastify. Fixed by an existing app.

express

orm, database

No

none, typeorm, prisma, mongoose or drizzle; database is postgresql, mysql or mongodb (MySQL documented but not verified; Mongoose implies MongoDB).

none; postgresql

distribution

No

none or internal. internal makes the workflows push the image to GHCR; the Dockerfile is written either way.

none

package-manager, node-version

No

npm, pnpm or yarn; Node major for the Dockerfile base image.

npm; 24

docs-tool

No

compodoc, typedoc or none.

compodoc

mode

No

new or existing. Informational: never means "update silently".

Derived: package.json present means existing

on-existing

No

ask, keep, update or replace, pre-answering the per-artifact question for scripted runs.

ask

publish, storybook, pages and ci-tests are ignored. A root package.json that is not a Nest app makes the skill ask whether to scaffold into a subdirectory or stop.

Outputs

  • The NestJS project: package.json, nest-cli.json, tsconfig*.json, .oxlintrc.json, .prettierrc/.prettierignore, unit and e2e test configs (Vitest or Jest), and optionally typedoc.json.

  • src/config/, src/app.module.ts, src/app.setup.ts, src/main.ts, src/health/, the sample src/books/ feature, and test/ e2e specs and app factory, each with specs. The scaffold’s Hello World files, the deploy script and @nestjs/mau are removed.

  • With an ORM: src/database/ wiring, an initial migration, ORM scripts and a Testcontainers global setup.

  • Dockerfile, .dockerignore, .env.example, and sonar-project.properties when Sonar is enabled.

  • A report: mode, location, resolved choices, the npm scripts written, versions and their source, each verification command and result (unverified items such as Docker-dependent e2e or MySQL called out), and warnings (review generated files, run migrations as a deployment step, SONAR_TOKEN needed).

No .gitignore, workflows, CHANGELOG.md or README.md are written; the orchestrator runs the dedicated skills for those next.

Execution flow

flowchart TD A["Start /iru-setup-nestjs-app"] --> B["Step 0: parse args"] B --> C["Step 1: survey; classify package.json"] C -- "non-Nest project at root" --> D{"Subdirectory?"} D -- stop --> STOP["End without changes"] D -- subdirectory --> C2 C --> C2["Announce from scratch vs update;\nask Update / Keep / Replace / Stop per artifact"] C2 -- Stop --> STOP C2 --> E["Step 2: collect identity and options"] E --> F["Step 3: resolve versions live"] F --> G{"New app?"} G -- yes --> H["Step 4: Nest CLI into temp dir, copy without overwriting"] G -- no --> I["Skip scaffold"] H --> J["Step 5: package.json, dependencies, scripts"] I --> J J --> K["Step 6: test, lint, format and tsconfig files"] K --> L["Step 7: application skeleton"] L --> M{"orm not none?"} M -- yes --> N["Step 8: persistence, migrations, e2e setup"] M -- no --> O["Step 9: Dockerfile and .env.example"] N --> O O --> P["Step 10: sonar properties when enabled"] P --> Q["Step 11: ORM generate and Prettier"] Q --> R["Step 12: lint, format, typecheck, test, coverage, build, docs, e2e, image"] R -- failure --> S["Fix what this skill wrote"] S --> R R --> T["Step 13: report"]

Dependencies

Invokes

None. It runs the Nest CLI, the package manager and optionally docker directly, and reads its own reference/ files (app templates, ORM variants, Docker and Sonar). Step 12 runs the commands that the iru-typescript-* gate skills and the workflows call, without invoking those skills. The generated code follows the iru-nestjs-code-one-task references.

Invoked by

None.

Source

SKILL.md on GitHub — the file this page was generated from.