This article will teach you how to implement JSON Web Token (JWT) Authentication with Node.js, PostgreSQL, TypeORM, ExpressJs, Redis, Docker, and Docker-compose. We will implement the assymetric (RS256 algorithm) JSON Web Token authentication manually without using any Node.js authentication library like PassportJs.
- List the Node.js API Routes
- User Login and Register Flow with JWT Authentication
- Defining Base and User Entities with TypeORM
- Defining Zod Schemas to Validate Request Body
- Create Middleware to Parse Zod Schema
- Password Management with Bcrypt
- Create Services to Interact with the Database
- Asymmetric Encryption (RS256 algorithm) Json Web Tokens
- Service to Sign Access and Refresh Tokens
- Error Handling in Express
- Create Authentication Route Controllers
- Create User Route Controller
- Create Authentication Middleware Guard
- Create the API Routes
- Authentication Routes
- User Routes
- Add the Routes to the Express Middleware Stack
- Run Database Migrations with TypeORM
- Inspect the Data with VS Code MySQL Extension
Read the entire article here: https://codevoweb.com/api-node-postgresql-typeorm-jwt-authentication
Articles in this series:
API with Node.js + PostgreSQL + TypeORM: Project Setup
API with Node.js + PostgreSQL + TypeORM: JWT Authentication
API with Node.js + PostgreSQL + TypeORM: Send Emails
