Files
main.tsmain
What you'll learn
- Read a specification and turn it into modules, controllers, services and DTOs without a step-by-step guide
- Load settings from .env with ConfigModule and read them with ConfigService
- Validate every body globally, refuse properties a DTO does not declare, and derive an update DTO from a create DTO
- Answer the API's errors as Nest does: 400 with the rules that failed, 404 naming what was not found, 204 for a deletion
Press Run tests to start the app. Its log appears here.Graded endpoints
The shelter's name comes from .env through ConfigService
Two cats to start with
The breed query narrows the list
One cat by its numeric id
A 404 that names what was missing
ParseIntPipe refuses it before the service is asked
A valid cat is created with the next id, and no breed is null
The global ValidationPipe answers with every rule that failed
forbidNonWhitelisted refuses it instead of dropping it in silence
An update carries only what changes
The update DTO keeps the create DTO's rules
A deletion answers 204 with no body
The removed cat is a 404
Tom, a year older, and Milo