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
ClsModulemounted as middleware for request-scoped user context- Soft-delete configuration on
NestExtendedModule.forRoot() - A global exception filter and the null→404 response interceptor
- A
.envwith the connection string andJWT_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:
| Method | Route | Behaviour |
|---|---|---|
GET | /resource | Paginated list (supports the query language) |
GET | /resource/:id | Fetch one (404 when missing) |
POST | /resource | Create (stamps createdBy) |
PATCH | /resource/:id | Update (stamps updatedBy) |
DELETE | /resource/:id | Soft 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:
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
# 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"