Hello everyone! I am going a describe Microservices with Redis using an example of a simple TODO application where two different types of users are available, Admin & Client user.

N.B. This tutorial needs some knowledge about NestJS.

If you want to check out other repository regarding this application on top of NestJS GitHub link and you can also find few other branches and tutorials are
1) Simple to-do application
2) Refresh token generator
3) Two Factor Authentication(2FA)

What admin can do?

Hello everyone ! I am going to describe Two Factor Authentication(2FA) in NestJS using a Todo application. So let’s jump in.

N.B. I already wrote this tutorial series for Todo application using — NestJS, JWT, PostgresSQL, PgAdmin4 and Docker. Feel free to look at it. Link- https://tushar-chy.medium.com/a-simple-todo-application-with-nestjs-typeorm-postgresql-swagger-pgadmin4-jwt-and-docker-caa2742a4295
and the code — GitHub

N.B. Refresh token generator using the same application. Link- https://tushar-chy.medium.com/jwt-refresh-token-generator-in-nestjs-application-54c5ab2c0da3
I recommand to understand the Refresh-token-generator. It will be better for this tutorial and code — GitHub

We are going to use otplib for secret generator & qrcode for keyUri. So let’s run the below command

// under…

Hello everyone! I am going to describe the JWT refresh token generator in NestJS using a TODO application. We are using -


You can check the initial stage of this article where this application is described- A simple todo application & git repo

Update .env file


Update config/default.yml file

expiresIn: 600
refreshExpiresIn: 120

Update config/development.yml file

secret: 'anyKey'
refreshSecret: 'noKey'

Update docker-compose.yml file under nestjs service


Update src/auth/jwt-strategy.ts file

Create src/auth/jwt-refresh-strategy.ts file…

N.B. Please finish the Part-1 first to understand rest of the tutorial

So our authentication is working properly. Let’s update a user’s profile by hitting /api/user — PATCH method. On successful update, you should able to see the below image-

To view the user information, use api/user — GET method & your screen will be -

NestJs & Docker Logo
NestJs & Docker Logo
NestJS & Docker

Aloha !!! This tutorial will be very basic of a development stack and required a basic understanding of Docker. But if you haven’t, don’t worry you can follow along with the instruction and will find it very easy. So let’s Jump in.

What is NestJS?
NestJS is a framework for building efficient Node.js server-side application with fully supports TypeScript and also makes use of Server frameworks Ex. Express.

What is TypeORM?
TypeORM is object-relational mapper library and can be used with TypeScript & JavaScript.

What is PostgreSQL ?
PostgreSQL is a powerful and advanced open-source relational database.

What is Swagger…

Tushar Roy Chowdhury

I am passionate programmer and always keep eyes on new technologies and scrutinize until get into a structure.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store