
Set up the Nestjs in practice development environment by cloning the one-start branch, installing front end and back end dependencies with npm, using node and an IDE such as Webstorm.
Implement the first rest endpoint for courses in NestJS, returning a data list from a shared course entity at /api/courses, and enable hot reload with ts watch and npm scripts.
Learn how to populate a MongoDB database for a Nestjs app using populate db script, connect via a MongoDB connection string, and query courses and lessons in a one-to-many relationship.
Validate incoming JSON payloads at the API boundary using NestJS pipes and class-validator decorators, turning interfaces into classes and returning a complete error payload.
Introduce NestJS pipes as chained transformations that convert http body values, turning a string into a number for sequential number field, with type checks and mongoose config to avoid deprecations.
Build the course screen and connect it to a backend endpoint by URL, add a find-by-url method in the controller and repository, and handle 404s while prepping the lessons endpoint.
Implement a NestJS back-end endpoint for fetching lessons with pagination using @Query to read courseId, sort order, page and page size. Validate inputs and prepare to query the database.
Implement login in the NestJS authentication controller by reading email and plaintext password from the http post body with the body decorator; query user model and 401 unauthorized if needed.
Learn how Nestjs middleware authenticates user requests by decoding the Json web token, storing user info on the request, and applying protection to the courses and lessons endpoints.
This Course in a Nutshell
If you don't know NestJs, it's like Angular but for the backend. With it, we can write our backend using the same concepts and object-oriented APIs that we already use to structure our Angular frontend: components, services, modules, pipes, etc.
NestJs is also quite similar to popular libraries that you might already be used to, such as, for example, the Spring library in the Java ecosystem, or ASP.NET MVC for the C# ecosystem.
Course Overview
In this course, you are going to learn from scratch how to design and develop a NestJs backend that will take the form of a REST API that queries a MongoDB database using the Mongoose ODM (Object Document Mapping) library. We will be providing a complete CRUD example showing how to perform the most common REST data retrieval and data modification operations using NestJs.
No prior NestJs, MongoDB or Mongoose knowledge is assumed as we will explain everything from scratch. We will cover all the essential NestJs concepts such as Modules, Controllers and injectable services.
We will learn in detail how to validate business data using a decorator based approach (with decorators like @IsString(), @IsPhoneNumber(), etc.) by leveraging the built-in NestJs Validation pipe.
We will also implement using NestJs commonly needed backend security functionality such as User Authentication, RBAC (Role-Based Access Control) Authorization, error handling, and cover more advanced NestJs concepts such as Filters, Pipes, Guards, interceptors and middleware.
Table of Contents
This course covers the following topics:
Introduction to NestJs
Running NestJs in Hot Reload and Debug mode
Writing our first NestJs REST endpoint
NestJs Modules, Controllers and injectable Services
Introduction to MongoDB
Setting up a cloud MongoDB database
Introduction to the Mongoose ODM library
Querying MongoDB from a NestJs REST endpoint
Complete CRUD example with NestJs and MongoDB
NestJs Filters and custom error handling
NestJs Pipes, building a custom pipe
Data Validation with class-validator and the Validation pipe
NestJs Middleware
User Authentication with NestJs
NestJs RBAC (Role-Based Access Control) Authorization
NestJs Guards
What Will You Learn In this Course?
After taking this course, you will feel comfortable designing and developing applications using NestJs. You will have learned everything that you need to know in practice for designing and developing production-ready secure backends using the NestJs framework.