nevo-gen is a one-shot CLI that produces a working NestJS microservice wired to your chosen transport.
npx nevo-gen <name> [flags]If @riaskov/nevo-messaging is installed locally, nevo-gen is on the local node_modules/.bin path.
| Flag | Default | Meaning |
|---|---|---|
-n, --name <name> |
(positional) | Service name (e.g. user, order) |
-t, --transport <kind> |
nats |
One of nats, kafka, http, socket |
-o, --out <path> |
./<name> |
Output directory |
-p, --port <number> |
8086 |
Listen port for bootstrap |
-f, --force |
off | Overwrite existing files |
-h, --help |
— | Print help |
For nevo-gen user --transport nats:
user/
├── src/
│ ├── main.ts # createNatsMicroservice bootstrap
│ ├── app.module.ts # imports UserModule
│ └── user/
│ ├── user.module.ts # ConfigModule + NEVO_NATS_CLIENT provider
│ ├── user.service.ts # extends NatsClientBase
│ └── user.controller.ts # @NatsSignalRouter with sample @Signal handlers
├── package.json # dev/build/start scripts + deps
└── tsconfig.json # TypeScript 6, ES2024, decorators on
The user.module.ts already includes the right factory (createNevoNatsClient / createNevoKafkaClient / etc.) and DI token.
npx nevo-gen user --transport nats
cd user
npm install
npm run devIn another shell:
const u = await client.query("user", "user.getById", { id: 1n })
// → { id: 1n, name: "Sample User" }Targets nats://127.0.0.1:4222. Run a broker:
docker run --rm -p 4222:4222 nats:2 -jsExpects a broker on localhost:9092. Use the docker-compose snippet in basics-kafka.md.
Binds to the given --port. Update app.module.ts to point at your real coordinator URL.
Starts a Socket.IO server on the given port plus a coordinator URL (replace with yours).
The CLI refuses to overwrite files by default:
Refusing to overwrite /path/to/user/src/user/user.service.ts (use --force)
Pass --force to replace, or delete the directory first.
Recommended next steps:
- Replace the sample methods with your real domain
- Add
@Schema()on every public method so the contract has types — see schema.md - Wire up a database in
user.module.ts - Add a
HealthRegistry— see health-checks.md - Call
setupNevoTracinginmain.ts— see observability.md
The companion CLI is nevo-contract, which fetches the running contract and generates a TypeScript client — see contracts.md.