Generated App

nest-cli g app produces a production-ready NestJS project that already follows the nest-extended conventions. This page describes what you get.

Project structure

A generated app wires up the runtime pieces for you:

  • Database + ORM configuration for your chosen adapter
  • ClsModule mounted as middleware for request-scoped user context
  • Soft-delete configuration on NestExtendedModule.forRoot()
  • A global exception filter and the null→404 response interceptor
  • A .env with the connection string and JWT_SECRET
  • With --auth: an Auth module and a Users module

HTTP API

Every resource generated with nest-cli g service exposes standard CRUD routes through the NestController base class:

MethodRouteBehaviour
GET/resourcePaginated list (supports the query language)
GET/resource/:idFetch one (404 when missing)
POST/resourceCreate (stamps createdBy)
PATCH/resource/:idUpdate (stamps updatedBy)
DELETE/resource/:idSoft delete (stamps deletedBy)

Auth flow

When generated with --auth, the app includes JWT authentication and a users module with the standard fields (firstName, lastName, email, password, phone, role). Routes are protected by default; mark public endpoints with the @Public() decorator:

cats.controller.ts
import { Public } from '@nest-extended/decorators';
 
@Public()
@Get()
findAll() {
  // accessible without a JWT
}

Error handling

The global exception filter translates database errors into clean HTTP responses:

POST /users  (duplicate email)
→ 400 Bad Request: "A user with this email already exists"
 
GET /cats/:badId
→ 404 Not Found        (via NullResponseInterceptor)

Zod or class-validator errors (depending on the --validator you chose) are returned as structured 400 responses.

Environment variables

.env
# Prisma / TypeORM
DATABASE_URL="postgresql://user:password@localhost:5432/db"
 
# Mongoose
MONGODB_URI="mongodb://localhost:27017/db"
 
# When --auth is enabled
JWT_SECRET="change-me"

Next steps