Documentation

Commands

A complete reference for every command available in your Nestled project.


First-time setup

nx g @nestledjs/generators:workspace-setup --name my-app

Run this once after cloning the template. It renames the workspace from nestled-template to your project name, starts Docker services, runs database migrations, and seeds initial data. The --name becomes your import namespace (@my-app/...), so keep it short, lowercase, with dashes.


The most important command

pnpm db-update

This is the command you'll run most often. After any change to your Prisma schema, run this to regenerate your entire stack:

pnpm db-update

Under the hood, it runs four steps in sequence:

  1. nx g @nestledjs/api:generate-crud — Reads your Prisma schema and regenerates CRUD resolvers for every model, with auth guards applied based on @crudAuth comments
  2. pnpm generate:models — Generates TypeScript models from the Prisma DMMF (Data Model Meta Format)
  3. nx g @nestledjs/shared:sdk — Generates GraphQL fragments, queries, and mutations for every model, then runs codegen to produce typed TypeScript operations
  4. nx g @nestledjs/api:custom — Creates custom module boilerplate for any new models (never overwrites existing custom code)

After running db-update, you'll typically also want to push your schema changes to the database:

pnpm prisma db push

This is the workflow

Design your Prisma schema → pnpm db-updatepnpm prisma db push → your app is updated. That's it. The more thought you put into your schema, the less manual code you write.


Development

CommandDescription
nx serve apiStart the API dev server on port 3000
nx serve webStart the web dev server on port 4200
pnpm sdk watchWatch GraphQL operations and auto-regenerate types
pnpm dev:apiAlias for nx serve api
pnpm dev:webAlias for nx serve web
pnpm typecheckRun React Router typegen + TypeScript type checking
pnpm typecheck:watchWatch mode for React Router typegen
pnpm storybook:web-uiLaunch Storybook for the component library

Database

CommandDescription
pnpm prisma db pushApply schema changes to the database (no migration files)
pnpm prisma:applyFormat schema + push (convenience combo)
pnpm prisma:formatFormat the Prisma schema file
pnpm prisma:generateRegenerate the Prisma client
pnpm prisma:migrateCreate and run database migrations
pnpm prisma:seedSeed the database with initial data
pnpm prisma:studioOpen Prisma Studio — a visual database browser
pnpm prisma:resetReset the database and re-seed (destructive)

db push vs migrate

During development, pnpm prisma db push is the fastest way to apply schema changes — it syncs your schema directly without creating migration files. For production deployments, use pnpm prisma:migrate to create versioned migration files that can be reviewed and applied consistently.


Code generation

CommandDescription
pnpm db-updateFull pipeline: CRUD + models + SDK + custom modules
pnpm generate:modelsGenerate TypeScript models from Prisma schema
pnpm sdkRun GraphQL codegen once
pnpm sdk watchRun GraphQL codegen in watch mode

Building for production

CommandDescription
pnpm build:apiBuild the API (generates Prisma client + webpack production build)
pnpm build:webBuild the web app (React Router production build)
pnpm start:apiStart the production API server (node dist/apps/api/main.js)
pnpm start:webStart the production web server (node apps/web/server.js)

Docker

CommandDescription
pnpm docker:upStart dev services (PostgreSQL, Redis, Mailhog)
pnpm docker:downStop dev services
pnpm docker:logsView last 50 lines of service logs
pnpm docker:buildBuild a production Docker image
pnpm docker:runRun the production Docker image (maps port 8000 → 3000)
pnpm docker:pushPush the Docker image to a registry

The Docker Compose file is at .dev/docker-compose.yml. It starts:

  • PostgreSQL 15 on port 5432 (user: prisma, password: prisma, database: prisma)
  • Redis on port 6379
  • Mailhog with SMTP on port 1025 and web UI on port 8025

Testing

CommandDescription
pnpm testRun unit tests
pnpm test:e2eRun the full E2E test suite (manages test DB automatically)
pnpm test:e2e:authRun only auth-related E2E tests
pnpm test:db:startStart the test database container (port 5433)
pnpm test:db:stopStop the test database container
pnpm test:db:resetReset the test database (destructive)

The E2E test runner (scripts/run-e2e-tests.sh) automatically starts the test database, runs migrations, executes tests, and cleans up. The test database runs on port 5433 so it doesn't interfere with your development database.


Nx workspace

CommandDescription
npx nx graphVisualize the workspace dependency graph
npx nx affected -t testRun tests only for projects affected by your changes
npx nx affected -t lintLint only affected projects
npx nx affected -t buildBuild only affected projects
pnpm lintLint the workspace
pnpm formatFormat code with Prettier
pnpm format:checkCheck formatting without writing changes

Utility

CommandDescription
pnpm cleanNuclear option — hard reset git, delete node_modules/dist/tmp, reinstall
pnpm vite:cleanClear Vite cache and dist folder
pnpm user:deleteDelete a user by running tsx scripts/delete-user.ts
Previous
Installation