
Master the NestJS framework, a powerful Node.js server-side tool that uses TypeScript, integrates with Express.js by default, and offers modular architecture, dependency injection, and rest and GraphQL APIs.
Install the Nest CLI and scaffold a new NestJS project with npm, then explore the created structure and prepare to learn NestJS basics in the next lecture.
Explore the nest project structure created by the nest CLI, including src, app.module.ts with the module decorator, controllers and providers, main.ts bootstrap, and supporting files like test and ESLint configurations.
Learn how NestJS controllers manage incoming HTTP requests and return responses. Use the controller decorator and the get decorator to define a base path like products and relative routes.
Learn to create a products controller with the nest CLI, implement a get handler for a get route, and understand the dist folder for transpiled production code.
Explore how NestJS automatically infers content types, returning a string yields text/html while an object yields application/json, and how decorators can explicitly set headers.
Create a NestJS post handler to add products using injectable service with an in-memory array. Extract title, description, and price from the request body and return generated id as JSON.
Learn how NestJS modules structure applications using root, feature, and global modules. Implement a product controller and service to handle post and get requests.
Fetch a single product by a dynamic id in a NestJS controller, reading the id with the param decorator and returning the product data or throwing not found when missing.
learn how to implement a NestJS put handler to update a product by id, replacing the full body and returning the updated product with nulls for missing fields.
Mastering NestJS controller fundamentals explains implementing a patch handler for partial updates, merging new product data by id, and distinguishing patch from put by updating only specified fields.
Implement a NestJS delete request in controller using @Delete, fetch the id from params, remove the product in the service via find and splice, and return product deleted successfully message.
Explore how the NestJS request decorator grants access to the Express request object, including headers, params, and query, complementing the body decorator and DTO for type-safe data handling.
Mastering NestJS demonstrates handling the response object with the response decorator and Express interface, showing how to send responses and access id, query params, and user agent.
Mastering NestJS shows how to extract query parameters with the query decorator in get requests, retrieving name, id and age from the URL and returning them with automatic type conversion.
Explore how NestJS manages HTTP status codes using the HTTP code decorator versus the response decorator, and learn when to rely on automatic handling or manual status setting.
Explore how NestJS uses the http status enum to set response statuses, using the http code decorator and the status values like okay and bad gateway to control codes.
Explore how NestJS pipes transform and validate incoming data, from string to integer, with built-in and custom pipes attached to route handlers for asynchronous data processing.
Learn how to use the built-in ParseIntPipe in NestJS to convert route parameters from string to number at the parameter level, with practical controller examples.
Learn how the built-in parse float pipe in NestJS parses floating point route parameters, overcoming the parse int pipe's inability to handle decimals such as price values.
Explore the built-in parse boolean pipe in NestJS, transforming request string values into boolean flags for routes, with examples showing admin versus user messages based on the isActive value.
Explore NestJS built-in parse array pipe, which converts string request parameters from query or body into arrays and can be configured with items to enforce element types like number.
Validate and transform incoming universally unique identifiers (uuids) with the built-in parse uuid pipe in nestjs, ensuring proper formatting by default or restricting to a specific version, such as four.
Mastering NestJS demonstrates the built-in validation pipe validating incoming payloads from query, body, and route parameters with decorators like isEmail and isString, applied globally with the use pipes decorator.
Learn to validate empty fields in NestJS using isNotEmpty and isEmpty decorators from class-validator, ensuring accurate messages for required fields like email and password, while allowing optional fields.
Learn to validate field length in Nestjs using a length validator with min and max values, as shown with name and password fields and their constraints.
Define custom validation messages for NestJS validators, using the message property with minlength and maxlength, and tokens like $constraint1, while recognizing some validators like isEmail don't support messages.
Mastering NestJS demonstrates validating a country field with the @IsEnum() validator, using a value array or an enum reference, with custom messages and the user input displayed.
Validate dates in NestJS using class-validator's isDate and isDateString, with class-transformer's type decorator to transform values into date instances. Test iso8601 date strings and date objects via postman.
Learn how to define optional fields in NestJS DTOs using the isOptional validator so missing properties bypass validation. Also distinguish isOptional from isEmpty to enforce or ignore validators appropriately.
Validate regex patterns in NestJS using the class validator matches decorator on the auth dto phone field, enforcing a 10–11 digit string with isString and an optional custom pipe.
Create a custom NestJS pipe using the injectable decorator and PipeTransform to transform and validate data, such as a 10–11 digit phone number, throwing errors on failure.
Explore how a custom pipe uses the metadata.type property to conditionally transform request arguments, such as transforming body data to uppercase via the transform method, while leaving params unchanged.
Implement a custom pipe to handle param type. Set metadata.type to param, parse int value, generate a random id of that length, and route via the controller using pipes.
Explore how metadata.metatype exposes parameter types in NestJS via decorators like param and body, handling string, number, and date values, with date conversion to UTC and request on invalid formats.
Understand how ArgumentMetadata metadata.data identifies the data type and value in a request (body, params, queries) and drives conditional processing, such as turning the name to uppercase.
Implement global pipes in NestJS to centralize validation, sanitization, and transformation for all requests, using app.useGlobalPipes in main.ts with a validation pipe and a custom phone auth pipe.
Explore how NestJS middlewares intercept incoming requests, perform validation and logging, and pass control to controllers, enabling reusable, non-intrusive request handling across the app.
Mastering NestJS teaches how to implement middleware by creating logging.middleware.ts, marking it injectable, implementing NestMiddleware with a use method that logs a date, calls next, and showing module registration.
Register and configure middleware in a NestJS app using the nest module interface and the configure method with a middleware consumer. Apply to routes and call next for proper flow.
Learn to implement route-specific middleware in NestJS by building a token middleware, validating authorization header tokens, and applying it to selected routes with the four routes method.
Develop a NestJS middleware to validate request content type, returning 400 when missing and 415 for content types not application json, and apply it to the /client route.
Demonstrate how route wildcards denoted by an asterisk match any URL segment and how middleware applies to all client routes under a controller path based on content type headers.
Master NestJS middleware by applying it to specific route handlers, such as get requests, while excluding post routes, using route objects with path patterns and method filters.
Master how to exclude specific routes from middleware in NestJS using the exclude method, by setting full paths and HTTP methods like post or get, and handling subroutes.
Master NestJS middleware by using the forRoutes method to target specific routes or apply a controller driven route approach to cover all routes within a controller for granular control.
Learn to implement NestJS middleware using a common class and a lightweight functional function, including a convert middleware that transforms request bodies to JSON and applies to routes.
Divide middleware into separate modules for authentication and filtering, and apply multiple middlewares on routes with proper order and next usage to control flow.
Mastering NestJS teaches how to apply global middlewares in two ways—wildcard route configuration and app.use—demonstrating when to use functional versus class middlewares and the dependency injection considerations.
Implement a password encryption middleware in NestJS that hashes passwords with bcrypt, validates user dto fields, and stores and retrieves users via a service and controller.
Explore guards in NestJS, understanding how they gate routes by examining requests to allow or deny access based on authentication, authorization, and execution guards.
Mastering NestJS teaches you to implement a guard with nest generate guard, explore canActivate and executionContext, and apply useGuards to protect routes with an RxJS observable-based, injectable guard.
Explore the execution context interface in NestJS and how guards use get arguments by index to access the request and its params, headers, and the response and next function.
Mastering NestJS demonstrates the getArgs method, which returns an array of all handler arguments. Destructure the request and response from the array to access properties like query, cookies, and headers.
Mastering NestJS teaches you to restrict access with guards by using canActivate to block routes for non-admin controllers, exposing admin and user controllers and a user service.
Mastering NestJS shows how the execution context abstracts different application types and how switchToHttp() transitions the execution context to the HTTP context, granting direct access to request and response objects.
Create an api key authorization guard in NestJS by validating the key from request headers using a user service, returning the user data or an unauthorized error.
Apply multiple guards in NestJS to a single route handler by enforcing an admin role via a header check. Guard precedence ensures the first guard runs before the second.
Mastering NestJS shows attaching custom metadata to route handlers with the set metadata decorator and retrieving it in guards via the reflector for dynamic role checks.
Master the better approach to attach custom metadata to NestJS route handlers by creating a roles enum and a custom decorator that uses set metadata.
Master NestJS role-based access by guarding route handlers with a roles guard, using a roles decorator and admin vs user roles to control post and get routes.
Learn how to assign multiple roles to a NestJS route using the roles decorator with a role enum array, and understand the spread operator requirement to avoid errors.
Register global guards in NestJS by configuring the app guard token in the module providers or using main.ts app.useGlobalGuards, enabling dependency injection with reflector and user service.
Explore how interceptors in nestjs sit between the client and route handlers, modify requests, validate criteria, transform responses, and apply at method, controller, or global levels.
Implement a nest interceptor via the cli, understand the intercept method, and log before and after using RxJS pipe and tap, then bind it to a route with UseInterceptors.
Create a transform interceptor in NestJS to modify response data by adding transformed and timestamp properties using the RxJS map operator, and bind it to a get route.
Modify outbound requests with NestJS interceptors to convert payloads to JSON and set the content-type to application/json, then attach custom response headers like x-request-id using the RxJS map operator.
Implement a NestJS interceptor to transform user data and remove the password field from responses.
Explore how an interceptor maps exceptions to responses using catchError and not found exception for invalid IDs, with the controller shaping errors before the response reaches the client.
Master data validation in NestJS by using an interceptor to validate request bodies at the root level, enforce required fields, and return bad request messages before reaching routes.
Mastering NestJS shows how to implement an auth interceptor that validates JWT tokens via the user service, throwing unauthorized on missing or invalid tokens, and securing get routes.
Learn how to apply global interceptors in NestJS, via the app module providers using the app_interceptor token and use class, or via main.ts with useGlobalInterceptors.
Connect a NestJS app to a MySQL database with TypeORM. Configure localhost:3306 with root and an empty password, and enable migrations and caching in a TypeScript class and decorators schema.
Define a product entity in NestJS using TypeORM, with entity and column decorators to map class fields to table columns and a primary key with defaults.
Implement create functionality in NestJS by building a products controller, service, and DTO, injecting the product repository, and saving new products to a MySQL database with TypeORM.
Fetch all products and a single product in NestJS by implementing get all and get one in the product service and controller, with price-based ordering and not found error handling.
Update a product by loading the existing record, throw not found if missing, merge update data with the product DTO via TypeORM merge, and save after validating the product name.
Learn how to delete a product in NestJS via a service and repository remove, including not-found handling and a controller delete route that parses the id.
Build a practical NestJS my store application with server API, EJS templating, MySQL, signup and login flows, product management, cookie and session authentication, JWT, bcrypt, file uploads, emails, and pagination.
Learn to render server-side templates in NestJS using EJS, configure view directories and templating engine, and render a home template with a welcome message.
Create a reusable navbar as an include in the views folder, using bootstrap classes and links for home and add product, then include it in the home template with EJS.
Create a home interface in NestJS by rendering static product cards from a public assets folder with images, names, and prices. Prepare for dynamic data from a database.
Implement an else block to display a 'no products available' message with an add product link when the database yields no products, styled with bootstrap and a cart icon.
Configure the add product route in nestjs with decorators on the app controller, adding a get for /my store/add product and rendering the page.
Create the add product interface by including the navbar and bootstrap, then build a centered form with product name, price, image, and a submit button with a cart icon.
Configure the edit product page by defining a get route in the app controller, rendering the edit product template, and wiring the navbar and bootstrap for a styled interface.
designs edit product interface by reusing add product template, uses a dynamic id route with a param decorator to fetch product from database, and binds name and price to inputs.
Fetches products from database by injecting the product service into app controller, uses get all to retrieve data, renders home and add product templates, and exports the service for MySQL.
Add the product image field to the database and dto, update the create route to redirect home, and configure the ejs form with multipart/form-data for image uploads using NestJS Multer.
Learn to upload product images in NestJS using Multer with a file interceptor and disk storage to public/uploads, configure custom file naming, and integrate the uploaded file with product data.
Explain updating a product in NestJS by rendering the edit template with product data, handling file uploads via Multer, and using post, put, or method override for submission.
Master the delete operation in NestJS by converting anchor links to a form with method override, posting to /product/delete with the product id, and redirecting to home after removal.
Implement authentication for the My Store app by adding sign up and login forms, and restrict add, edit, and delete actions to authenticated users.
Create a sign up page with username (email), password, and confirm password fields; add a navbar sign up link, configure its route, and render the sign up template with bootstrap.
Build a sign-up form using a bootstrap-based grid, with username (email), password, and confirm password fields, show/hide button, labeled inputs, and a ready sign-up interface.
Implement a show/hide password toggle for the signup form by referencing password and confirm password inputs, switching their type, and updating the icon on click.
Validate passwords by matching password and confirm password before sign up. Implement a validatePassword function, call it on form submit, and update a helper text while typing to show mismatches.
Build a NestJS signup flow by creating a users entity and DTO with email validation, plus a controller and service that persist new users to the database via a repository.
Create and configure the login page by copying the signup template, updating the title and action, removing the confirm password and validation, and rendering the login via the user controller.
Validate login details against the database by fetching user credentials from the login form via a post route, then set a cookie indicating login status to guide redirects.
Control edit, delete, and add product visibility based on login state by reading cookies in a NestJS app. Install cookie parser to expose cookies as key-value pairs via request.cookies.
Render the dom based on login status by using the cookie value to hide edit and delete buttons, hide add product menu, and replace signup/login with logout in the navbar.
Implement logout by defining a get route that sets the is_logged_in cookie to false and redirects to the home page, and update the navbar link to /user/logout.
Configure express-session as a middleware to store unique sessions on the server, avoiding cookie tampering, and test by logging req.session.id to show distinct IDs per window and tab.
set and read the session cookie using request.session to track login. define is logged in on the session property, default false, and render content based on it.
Move session storage from memory to a MySQL database to support many concurrent users by using the Express MySQL session store and creating the sessions table.
Destroy the user session on logout by calling request.session.destroy and clearing the connect.sid cookie, ensuring the session is removed from the database and cookies are cleared.
Master session storage optimization in NestJS by ensuring sessions are created only for registered users, adding username and message to the session, and updating login flow to display validation messages.
Implement jwt token authentication in nestjs by signing a payload with the username and configuring the jwt module. Store the token in a session cookie to handle login and logout.
Learn how to build an auth middleware in NestJS that verifies a JWT on every request, protecting routes like add product and edit product by redirecting unauthenticated users to login.
Implement token-based conditional rendering in NestJS by managing a global isLoggedIn flag via middleware, decoding tokens, and allowing public paths such as login, signup, and logout.
Mastering NestJS demonstrates hashing user passwords with bcrypt on sign up, storing hashed values in the database, and excluding the sign up route from middleware.
Master the login flow in NestJS by validating credentials with bcrypt's compare method, comparing the original and hashed passwords, and generating a token upon success.
Finalize the My Store NestJS app by adding signup checks for existing users, redirecting with messages, and displaying success or error alerts on login and signup templates.
Explore the dynamic universe of server-side web development with this meticulously crafted Nest.js course, tailored for both aspiring learners and seasoned professionals looking to master server-side TypeScript. This progressive guide takes you on a hands-on exploration of Nest.js, with a new generation development approach with typescript.
In this course, you’ll learn the correct approach to tackle real-world projects - ensuring that you gain practical skills that are directly applicable in professional settings.
Here are the key features of this course:
NestJS Basics
Controllers
Pipes
Guards
Interceptors
Middleware
CRUD with MySQL
TypeORM
REST APIs
Cookies
Session
JWT
BcryptJS
Working with MongoDB
Mongoose
Practical assignments & more...
Master NestJS Fundamentals → Grasp the foundational principles like Controllers, Pipes, Guards and Middleware
CRUD Operations with MySQL and MongoDB → Master techniques for building robust web applications and APIs with RDBMS and NoSQL databases.
Interceptors → Make use of interceptors that intercept incoming and outgoing requests in your application to modify request and response data, execute additional logic, or handle errors globally.
By the end of this course, you will be able to:
Build scalable and maintainable Node.js applications
Effectively use TypeScript in your NestJS projects
Master the core concepts of NestJS architecture
Create robust RESTful APIs
Implement advanced features like middleware, pipes, interceptors, and guards
Write comprehensive tests for your code