NestJs - Build Modern APIs in NestJs with Unit Testing

Build Modern API with NestJs with MongoDB & Postgres, including Authentication, Typescript, TypeORM, Unit & e2e testing

4.63 (33 reviews)
Udemy
platform
English
language
Web Development
category
instructor
NestJs - Build Modern APIs in NestJs with Unit Testing
376
students
9 hours
content
Dec 2021
last update
$19.99
regular price

What you will learn

Develop and full featured API with NestJs

Best practices of Authentication & Authorization

Data Validation & Error Handling using Pipes

How to implement pagination & search

How to generate coordinates of address with GeoCoder

Uploading images on AWS S3 Bucket

How to use Passport for authentication

How to Protect Routes from unauthorized user

How to build a custom decorator

How to build a custom guard

Using TypeORM for database interaction

Persisting data with databases like MongoDB & Postgres

Understand Database relationships

Writing Unit Tests for complete API

Writing e2e Tests

How to deploy API on Heroku

Description

If you want to build a powerful API in the modern backend framework NestJs or if you want to learn how to unit test API then welcome to this Ultimate NestJs course.


NestJs is a Node.js framework for building efficient, reliable, and scalable Node.js server-side applications. NestJs is a complete framework that will help us to perform everything whether it is authentication or testing a complete API, NestJs provides us everything that we want. The architecture of NestJs is unmatchable.


Throughout this course, we will use TypeScript that will level up our development. Typescript will help us to write neat and clean code. We will be able to find our errors and bug right on the spot.


NestJs provides us a lot of flexibility by providing a lot of modules, when it comes to testing, NestJs provides us with Testing Module that makes Unit testing fun. Connecting to a database whether it is Relational (SQL, POSTGRES, etc) or NoSQL (MongoDB) is just fun and can be done in one line of code.


Really NestJs has made life a lot easier when it comes to building backend applications. The API built with this amazing framework is highly testable, scalable, loosely coupled, and easily maintainable applications.


Below are some points that we will cover in this course:


  • We will discuss what is NestJs and its CLI

  • Build a complete restaurant API

  • Use MongoDB to store our data

  • Add Pagination and Search in our API

  • Best practices for Error handling & Validations with PIPES

  • Generate the coordinates of the restaurant address

  • Uploading multiple images of the restaurant to AWS S3 Bucket

  • Add Jwt Authentication with Passport

  • Authorization of Roles with Guards

  • Build a CRUD Library API with Postgres & TypeORM

  • Unit Testing of complete API

  • e2e Testing to API

  • Deploying API on Heroku



Interested in learning this amazing NestJs framework for building your next backend API? Then Enroll now and I will see you in the course. Happy Coding!!!


Content

Introduction

Introduction to the Course
DEMO of API
What is Nest.js & Why we need it?
How to Follow the Course & Code?

Setting up Environment

Installing all required tools

Setup / Overview of Nest.js

Installing Nest CLI & Creating app
Understanding the folder structure
Nest.js Modules
Nest.js Controllers
Nest.js Service & Providers
Connecting to MongoDB with mongoose

Let’s start Restaurant API with Nest

Creating Restaurant Schema
Get all Restaurants
Create a new Restaurant
What is DTO?
Creating a Restaurant DTO
Get Restaurant by ID
Update Restaurant by ID
Delete Restaurant

Adding Search & Pagination to API

Adding Search
Adding Pagination

Validation, Pipes & Error Handling

What are Pipes?
Using Validation Pipe Globally
Adding Validation Rules in Update DTO
Invalid Mongoose ID Error

Generating Restaurant Location

What is GeoCoder
Generating Coordinates & Address
Saving Location in Restaurants

Upload Restaurant Images to AWS S3

Create Bucket on S3
Getting files through File Intercepter
Uploading images to S3
Saving Images in Restaurant
Delete Restaurant Images

Authentication with Passport JWT

Generating Auth Module
Creating User Schema
Sign up DTO with Validators
User Sign up
37. Hash user password while Sign up
Handle Duplicate Email Error
Login User
Setting Up JWT & Passport
Sign JWT token on Login

Protecting Routes with Guards & Custom Decorators

Setting Up JWT Strategy
Using AuthGuard to Protect Routes
Current User Decorator
Saving Current User in Restaurant
Creating User Roles Guard
Roles Decorator
Authorize Restaurant Ownership

Adding Meals in Restaurant

Creating Meal Model
Create Meal DTO
Creating a Meal
Getting all Meals
Get Meal by ID
Update Meal
Delete Meal

Library API with TypeORM & Postgres

Create Library Project
Install & Setup Postgres & pgAdmin
Connecting to Postgres Database
Create Book Entity
Create new Book
Get all Books & Book by ID
Update Book
Delete Book

Database Relationships

Relations & Types of relations
Create User Entity
Adding Books & User Relation (OneToMany & ManyToOne)

Unit Testing Restaurant API - Part 1

What is Unit Testing?
Write first unit test in Restaurant Service
Testing RestaurantsService - findAll
Testing RestaurantsService - create
Testing RestaurantsService - findById
Testing RestaurantsService - updateById
Testing RestaurantsService - deleteById
Testing RestaurantsService - uploadImages
Testing RestaurantsService - deleteImages
First unit test in Restaurant Controller
Testing RestaurantController - getAllRestaurants
Testing RestaurantController - createRestaurant
Testing RestaurantController - getRestaurantById
Testing RestaurantController - updateRestaurant
Testing RestaurantController - deleteRestaurant
Testing RestaurantController - uploadFiles

Unit Testing Restaurant API - Part 2

Testing Auth Service
Testing AuthService - signUp
Testing AuthService - login
Testing Auth Controller
Testing AuthController - signUp
Testing AuthController - login
Testing JwtStrategy

e2e Testing Restaurant API

What is e2e Testing
Testing Authentication Routes
Testing Restaurants POST protected Routes
Testing Restaurants GET Routes
Testing Restaurants PUT & DELETE Routes

Deployment

Preparing API for Deploy
Deploy API on Heroku

End of the Course

Congratulations!!!

Reviews

Ikenna
May 11, 2022
The videos are short and are broken down to easy to understand modules. Thank you very much for doing this both for MongoDB and Postgres using TypeORM.
Usmanbutt
February 15, 2022
An excellent course; I highly recommend it. This course has taught me a lot of techniques for testing. love this course....
Abdul
February 12, 2022
Best course of nest js. Tutor explain each and every concept in good manner. Good course for learner who want to learn nest js
Zunair
February 5, 2022
I respect your dedication to teaching the naive graduates who have no one to look up to. Awesome content and awesome energy. A sweet and simple example to start with this concept. Thank you so much, sir!
Haider
February 2, 2022
Exactly what I was looking for. Again a good experience with this instructor. Unit testing part was really valuable.

Charts

Price

NestJs - Build Modern APIs in NestJs with Unit Testing - Price chart

Rating

NestJs - Build Modern APIs in NestJs with Unit Testing - Ratings chart

Enrollment distribution

NestJs - Build Modern APIs in NestJs with Unit Testing - Distribution chart

Related Topics

4459176
udemy ID
12/24/2021
course created date
12/27/2021
course indexed date
Bot
course submited by