nestrs-scaffold — the binary you run is nestrs-cli. It scaffolds new single-crate applications, generates source files, and runs a lightweight diagnostic against your toolchain and Cargo.toml. Unlike the Nest CLI, it stays entirely within Cargo-native workflows and does not add Node-style scripts, monorepo management, or library packaging.
Install
1
Install from crates.io
2
Verify the binary
The crates.io package is
nestrs-scaffold because the name nestrs-cli is already taken. The installed binary is nestrs-cli in either case..cargo/config.toml as run -p nestrs-scaffold --bin nestrs-cli --.
Available commands
The
db family ships behind the db Cargo feature (it pulls in sqlx and tokio as CLI dependencies). Install it with:nestrs-cli db … fails with a clear message instead of producing a half-built binary.
nestrs-cli db
nestrs-cli db is the migrations + seeding runner. It works on plain SQL migration files — there is no DDL-diff engine (synchronize) or entity auto-discovery; those belong to full ORMs.
Global flags
migrate add
Writes empty SQL files you fill in. The naming convention is sequence-numbered —<NNN>_<name>.sql for single-shot, or <NNN>_<name>.up.sql + <NNN>_<name>.down.sql with --reversible. NNN is a zero-padded 3-digit sequence derived from the largest existing migration, incremented by one (deterministic, greppable, sortable — collisions surface immediately at add-time).
migrate run / revert / info
run applies pending migrations up; revert walks down (set --target-version 0 for a full revert). info lists applied and pending migrations. The sqlx backend uses sqlx::migrate::Migrator under the hood, so _sqlx_migrations is the recording table.
seed
Two modes:--bin <name>— pass-through tocargo run --bin <name>in the current directory. The resolved URL is forwarded to the seed binary as bothDATABASE_URLandNESTRS_DB__URL. You own the seed binary; the common case is a Rust bin that composes withCrudService<T>and your app’s services.--seed-file <path>— execute a SQL file against the resolved URL viasqlx::raw_sqlinside an explicit transaction, so a failedINSERTmid-file rolls back earlier rows. The escape hatch forpg_dump-style fixture dumps.
SqlxDatabaseModule, and the CRUD guide for #[crud] controllers over the same pool.
nestrs-cli new
nestrs-cli new <name> creates a ready-to-run single-crate application. Run it from any directory — it creates a new subdirectory named after your project.
Flags
Generated project structure
Afternestrs-cli new billing-api, your project contains:
Cargo.toml
Cargo.toml
src/main.rs
src/main.rs
The generated entry point wires up a
AppModule with a single controller and service, a health check endpoint, metrics, and request tracing. The --strict flag adds #![deny(unsafe_code)] at the top..env and .env.example
.env and .env.example
Both files are created with identical default content:
.env is listed in .gitignore so it stays local. Commit .env.example to source control.Dockerfile
Dockerfile
A two-stage Docker build targeting
debian:bookworm-slim. The binary name matches your project name.README.md
README.md
A starter README with development, production, and Docker instructions. The app, health, and metrics URLs are pre-filled based on the generated
main.rs defaults:- App:
http://127.0.0.1:3000/api - Health:
http://127.0.0.1:3000/health - Metrics:
http://127.0.0.1:3000/metrics
nestrs-cli doctor
nestrs-cli doctor is a lightweight sanity check you run from the root of a nestrs crate (where Cargo.toml lives). It does not replace cargo check or your CI matrix — use it as a first-pass hint list.
What it checks
1
Toolchain versions
Runs
rustc --version and cargo --version and prints the results.2
Cargo.toml feature flags
Reads the local
Cargo.toml and reports which nestrs feature flags it detects: openapi, otel, ws, graphql, and microservices. It also queries cargo metadata to count the total resolved feature flags on the nestrs package.3
Source file heuristics
Recursively scans
src/**/*.rs and flags common mismatches, such as:- Calling
enable_openapi()without theopenapifeature enabled inCargo.toml - Referencing
configure_tracing_opentelemetrywithout theotelfeature - Calling
enable_graphqlwithout thegraphqlfeature - Using
nestrs_openapi::paths without the feature enabled
Scope compared to the Nest CLI
The Nest CLI covers application lifecycle management, monorepos, publishable library packages, and npm-style scripts. nestrs intentionally stays closer to Cargo and normal Rust workflows.The nestrs CLI focuses on file and code generation and a single-crate
nestrs-cli new skeleton. It does not replace Cargo for workspaces, libraries, or task runners.