@verkut/nx-nest-service
v0.0.1
Published
Nx plugin: scaffolds the approved NestJS + Prisma microservice (DDD layers, @verkut/* wiring) and workspace setup
Readme
@verkut/nx-nest-service
Nx plugin that scaffolds the org-approved NestJS + Prisma microservice (Clean Architecture / DDD layers, @verkut/* wiring, Zod validation, Swagger, Redis, Prometheus metrics) — the same architecture as apps/api in the template repo.
Generators
init — workspace setup (idempotent)
Runs automatically on nx add @verkut/nx-nest-service. Safe to re-run — a second invocation produces zero changes.
- adds the runtime/dev dependencies to the root
package.json(@verkut/*from public npm,@nestjs/*,@prisma/*, prisma, pg, zod, nestjs-zod, envalid, helmet, ioredis, …) - creates
.npmrc(onlypublic-hoist-pattern[]=@prisma/*for the Prisma driver adapter) if missing - creates
docker/docker-compose.develop.yml(postgres + redis) if missing - creates/extends
.env.example - extends
pnpm-workspace.yamlonlyBuiltDependencies - injects the
/* nx-nest-service:scopes */anchor intoeslint.config.mjsdepConstraints - ensures
.env/swagger.jsonare gitignored
service — generate a microservice
nx g @verkut/nx-nest-service:service payment-service --domain=payment --domainPlural=payments
nx g @verkut/nx-nest-service:service worker --no-example # bare skeleton, no reference domain| Option | Default | Description |
|---|---|---|
| name | — | Service name, kebab-case (positional) |
| directory | apps/<name> | Target directory |
| domain | example | Reference bounded-context name (singular) |
| domainPlural | <domain>s | Plural (set explicitly for irregular plurals: category → categories) |
| example | true | --no-example scaffolds the skeleton without the reference domain |
| displayName | <Name> Service | Swagger title |
| httpPortEnv | API_HTTP_PORT | Env var holding the HTTP port |
| tags | — | Extra Nx tags (comma-separated); scope:<name> + type:app are always set |
What you get: src/cli (main + seed entry points), src/api/http/v1 (decorators, guards, Zod pipes, backoffice controller), src/domain/<domain> (constants/dto/exceptions/services/usecases/rules), src/infrastructure (envalid config, Prisma via @prisma/adapter-pg, Redis, seeding, validation), prisma/schema.prisma (moduleFormat="cjs" — required for the webpack CJS bundle), project targets (build → depends on prisma-generate, serve, seed, prisma-migrate-*, prune*), and a scope:<name> depConstraint appended to the root eslint.config.mjs.
Prisma migrations are not generated — create the first one yourself:
nx prisma-migrate-dev <name>Removing a generated service
nx g @nx/workspace:remove <name>Then manually delete its scope:<name> block from the root eslint.config.mjs depConstraints (the remove generator does not know about it), and drop the service's DB schema/tables if a migration was already applied.
Publish to public npm
# npm auth required: npm login, or NPM_TOKEN in CI (publishConfig.access = public)
nx build nx-nest-service # dist includes files/, generators.json, schema.json
nx release version --projects=nx-nest-service
nx release publish --projects=nx-nest-serviceUse in another Nx workspace
nx add @verkut/nx-nest-service # installs from public npm + runs init
nx g @verkut/nx-nest-service:service paymentsDevelopment notes
- Templates live in
src/generators/service/files(skeleton) andfiles-domain(reference domain); all carry a.templatesuffix,__token__placeholders in file names, EJS in contents. - The template source of truth is this plugin.
apps/apiin the template repo is the golden reference — parity is verified by regenerating it (nx g @verkut/nx-nest-service:service api2 --displayName='Myorg API'+ diff).
