How to create an Authentication Module with JWT in NestJs

Authentication

Preliminary

Prerequisites

Setting up NestJs

scaffolding project

Scaffold Auth Module

scaffolding auth module
auth folder and auth.module.ts
auth folder and auth.module.ts
Auth folder and Auth module scaffolded by nest CLI
AuthModule Class in auth.module.ts
Updated app.module.ts
scaffolding auth controller and service
Updated auth folder with controller and service

Database Setup

PgAdmin landing screen
creating and saving database
installing typeorm and postgres
Config folder and typeorm.config.ts file
typeorm.config.ts
updated app.module.ts with TypeOrmConfig
user.entity.ts
User Entity
user.repository.ts
User Repository
app.module.ts
auth.service.ts

Sign Up Process with Authentication

Updated Folder Structure
auth-signup.dto.ts
class validator installation
auth-signup.dto.ts
Updated user.repositry.ts
Updated auth.service.ts
auth.controller.ts
endpoint testing on postman
user table with data stored on PostgreSQL
bcrypt installation
updated user.entity.ts
encrypting password method in user.repository.ts
updated user.repository.ts
delete user table on postgresql
user table with hashed password and salt

Sign In Process with Authentication

updated folder with auth-signin.dto.ts
auth-signin.dto.ts
new folder structure
auth-signinresponse.dto.ts
updated user.entity.ts
user.repository.ts
user-jwt-response.interface.ts
install passport and jwt
update auth.module.ts
updated auth.service.ts
updated auth.controller.ts
testing signin endpoint

A Tech Enthusiast | I constantly learn new software concept and blog about it.