
See what this section covers: NestJS fundamentals, project setup, application structure and the types of applications you can build.
Compare NestJS, Express and Fastify.
Install the Nest CLI, create your first NestJS project and start the development server.
Explore the starter files and follow the bootstrap process in main.ts, from creating the Nest application to listening for incoming requests.
Use the project’s npm scripts to run NestJS during development, compile the application and start the production build.
Explore NestJS application types, including REST APIs, GraphQL, WebSockets, microservices, background workers and standalone applications.
Discover how NestJS modules, controllers and providers work together as we build an in-memory Tasks API.
Create the tasks feature and explain how modules organize dependencies, controllers handle requests and providers supply application functionality.
Create a NestJS service, register it as a provider and inject it into a controller to separate application logic from request handling.
Define create and update DTOs for your Tasks API. Explain optional properties and the difference between TypeScript types and runtime validation.
Build CRUD operations using an in-memory task array. Generate IDs, update allowed properties and throw NotFoundException when a task does not exist.
Build REST endpoints with NestJS route decorators, read bodies and parameters, and delegate task operations to TasksService.
Use an API client to create, list, retrieve, update and delete tasks. Verify responses for successful requests, missing tasks and invalid IDs.
Configure dependencies with useValue, useFactory, useClass and useExisting. Inject symbol tokens and demonstrate how a service alias shares the existing instance.
Share TasksService with ReportsModule using module imports and exports, allowing reports to read the existing task data.
Create and register a global ClockModule, then inject its exported ClockService into ReportsService without importing ClockModule again.
Demonstrate circular dependencies between TasksService and ReportsService, resolve service and module references with forwardRef, and restore the simpler design.
Explore the stages a request passes through in NestJS and identify where middleware, guards, pipes, interceptors and exception filters fit.
Create and register request-logging middleware. Observe when it runs and use next() to pass control to the remaining request pipeline.
Build an authentication guard using ExecutionContext, attach a demo user to the request and reject requests with missing or invalid demo credentials.
Create a Roles decorator, read its metadata using Reflector and apply a roles guard to control which users can access an endpoint.
Create a CurrentUser parameter decorator to retrieve the user attached by the authentication guard and simplify controller methods.
Apply DTO validation decorators and configure ValidationPipe to transform inputs, reject invalid data and control unexpected request properties.
Distinguish the application lifecycle from the request lifecycle and explore what happens when NestJS starts and shuts down.
Implement OnModuleInit to run initialization logic after the host module’s dependencies have been resolved, and observe the hook through application logs.
Implement startup and shutdown hooks in a lifecycle demo service. Start a background timer, track its activity and clear it during shutdown.
Enable shutdown hooks, explain SIGINT and SIGTERM, and observe how NestJS runs cleanup hooks when the application receives a shutdown signal.
Close a NestJS application programmatically using app.close() and compare its lifecycle-hook behavior with shutdown triggered by operating-system signals.
Explore how to manage application settings and organize NestJS modules as your backend grows.
Install and configure ConfigModule, load settings from an environment file and make ConfigService available throughout the application.
Define a Zod schema for application settings, validate values during startup and reject missing or invalid configuration with clear errors.
Inject ConfigService and use environment settings to configure application behavior instead of hardcoding values.
Group related settings into a named configuration factory using registerAs, then access those settings through ConfigService.
Organize application responsibilities into feature modules and explain when to share providers through explicit imports or global modules.
Create MailModule and MailService, inject mail settings and expose an endpoint that logs and returns an email preview without sending an email.
Convert MailModule into a dynamic module and implement forRoot so the importing application can supply settings through returned module metadata.
Explain why an in-memory array cannot provide permanent storage and explore how PostgreSQL and Drizzle ORM will add persistence to the Tasks API.
Create a PostgreSQL database on Neon, configure the connection string and install Drizzle ORM and its database tooling.
Define the tasks table using Drizzle’s PostgreSQL schema tools, then generate and apply migrations to create the database structure.
Create a DatabaseModule and injectable database service, initialize the PostgreSQL connection and close the connection pool during application shutdown.
Create a repository for task database operations using Drizzle queries, keeping persistence logic separate from TasksService.
Replace the in-memory task array with repository calls, update service methods for asynchronous database operations and verify that records survive an application restart.
Write and run a seed script to populate PostgreSQL with sample tasks for development and API demonstrations.
Connect task history records to tasks using a foreign key and explain how referential integrity and cascade deletion affect related data.
Update a task and insert its history record in one transaction. Demonstrate how rollback prevents partial changes when an operation fails.
Preview the API improvements we’ll implement in this section.
Return tasks in pages and include pagination metadata.
Filter tasks by status, search by title and control the order of results.
Configure Swagger UI to explore and test our NestJS API.
Describe request properties and endpoint operations using Swagger decorators.
Describe successful responses and error responses.
Move response schema definitions into reusable DTO classes.
Introduce versioned endpoints using NestJS API versioning.
Preview account authentication, session management and task ownership.
Define the users table and its authentication fields.
Implement database operations for creating and finding users.
Add registration logic and password hashing.
Expose authentication endpoints and validate incoming requests.
Verify credentials and issue signed access tokens.
Validate access tokens and identify the authenticated account.
Demonstrate protected requests and resolve an authentication issue.
Store and manage refresh sessions in PostgreSQL.
Replace refresh tokens when renewing access to the API.
Accept refresh requests and return updated tokens.
Revoke the submitted refresh session to prevent further token renewal.
Scope database queries to the authenticated owner.
Pass the authenticated account through task operations.
Verify that accounts cannot access each other’s private tasks.
Investigate why fetching tasks fails in Swagger while working in postman.
Preview how workspaces, members and projects fit together.
Define workspace storage and its relationships using Drizzle ORM.
Implement database operations for creating and retrieving workspaces.
Expose protected endpoints for workspace operations.
Verify workspace creation and retrieval through API requests.
Explain how accounts join workspaces and share access.
Implement database operations for workspace membership.
Understand when to use application events, background jobs and scheduled tasks.
Publish a task-created event and handle it with an event listener.
Connect to Redis, enqueue notification jobs and process them in a worker.
Use NestJS scheduling to periodically remove expired refresh sessions.
Learn NestJS 12 from scratch by building a project-management backend with NodeJS, TypeScript and PostgreSQL, then connect it to an Angular frontend.
This complete beginner course explains concepts step by step as you use them. You’ll understand how NestJS organizes an application, how dependency injection works and what happens when a request reaches your API.
Start with a simple in-memory Tasks API, then add database storage, authentication, workspaces, projects, background jobs and real-time notifications. Finally, test your service, package the backend with Docker and deploy it to Render.
What you’ll learn:
• NestJS fundamentals: modules, controllers, services, decorators and dependency injection.
• Custom providers, provider tokens, global modules, provider scopes and circular dependencies.
• The request lifecycle: middleware, guards, pipes, interceptors and exception filters.
• Application lifecycle hooks, resource cleanup and graceful shutdown.
• Environment configuration, Zod validation and configurable dynamic modules.
• PostgreSQL on Neon with Drizzle ORM, database schemas, relationships and migrations.
• REST API development with CRUD operations, pagination, filtering, sorting and searching.
• API versioning and Swagger documentation, including response DTOs that keep controllers readable.
• Registration, login, password hashing and JWT authentication.
• Refresh-token rotation, logout and ownership checks that protect each account’s tasks.
• Workspaces, team membership, membership permissions and basic projects.
• Application events, Redis on Upstash, BullMQ background jobs, retries and scheduled tasks.
• Real-time notifications using authenticated WebSocket gateways, SocketIO and account-specific rooms.
• Service unit testing with Jest and mocked dependencies.
• Docker images, containers and backend deployment to Render.
• Angular fundamentals: standalone components, templates, signals and application configuration.
• Angular forms, validation, built-in control flow and HTTP requests with HttpClient.
• Connecting Angular to your NestJS API to log in, display private tasks and create new tasks.
The lessons start with practical problems and introduce the NestJS features that solve them. You’ll write code as you learn, with demonstrations that show how the pieces work together.
Source code is included so you can follow along, review each section and continue experimenting.
Who is this course for?
JavaScript and TypeScript developers learning NestJS, frontend developers moving into backend development, and NodeJS developers who want a structured approach to building APIs.
Basic JavaScript, TypeScript and npm knowledge is recommended. No previous NestJS or Angular experience is required.
By the end, you’ll have built and deployed a NestJS project-management API, connected an Angular frontend and gained a practical understanding of backend application development.