API with Node.js + PostgreSQL + TypeORM

API with Node.js + PostgreSQL + TypeORM: Project Setup

API with Node.js + PostgreSQL + TypeORM: Project Setup

In this article, you'll learn how to set up a Node.js project with TypeScript, ExpressJs, PostgreSQL, TypeORM, and Redis. Also, you will learn how to run Postgres and Redis servers with Docker.

Topics Covered

  • Setup Node.js with Express, PostgreSQL, Redis, and TypeORM
    • Creating PostgreSQL and Redis Database with Docker
    • Setup Environment Variables with Dotenv
  • Initialize a New TypeORM Express App
  • Connecting an Express application with PostgreSQL
  • Connecting an ExpressJs application to Redis
  • Run the Express Server

Read the entire article here: https://codevoweb.com/api-node-postgresql-typeorm-project-setup

API with Node.js + PostgreSQL + TypeORM: JWT Authentication

API with Node.js + PostgreSQL + TypeORM: JWT Authentication

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.

Topics Covered

  • 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

API with Node.js + PostgreSQL + TypeORM: Send Emails

API with Node.js + PostgreSQL + TypeORM: Send Emails

In this article, you'll learn how to send development and production-ready emails with Nodemailer, Node.js, PostgreSQL, and TypeORM. We will include the Email verification feature in the API to ensure the users provide valid email addresses during the account registration process.

Topics Covered

  • Setting up Express.js with Pug Templating Engine
  • Create a Utility Class to Send Emails
    • Require the Nodemailer Credentials
    • Define the Email Class Attributes
    • Create a Nodemailer Transporter
    • Create a Method to Generate the Email Templates
    • Create a Method to Send the Emails
  • Creating the Email Templates with Pug
  • Create the User Entity with TypeORM
  • Database Schema Migration with TypeORM
  • Update the User Register Controller
  • Add a Controller to Verify the Email
  • Update the Login Controller

Read the entire article here: https://codevoweb.com/api-node-postgresql-typeorm-send-emails

Node.js, Express, TypeORM, PostgreSQL: CRUD Rest API

Node.js, Express, TypeORM, PostgreSQL: CRUD Rest API

In this article, you'll learn how to build CRUD RESTful API with Node.js, ExpressJs, TypeORM, and PostgreSQL. We will define the database schema with TypeORM and run the migration command to push the TypeORM schema to the database. Next, we will create higher-level CRUD function to perform the CRUD operations.

Topics Covered

  • Node.js, TypeORM, PostgreSQL CRUD RESTful API Overview
  • Project Structure
  • Model Data with TypeORM and PostgreSQL
    • Define a Base Entity
    • Add One-to-Many Relationship to User Entity
    • Complete User Entity
    • Create a Post Entity
  • Create Validation Schemas with Zod
  • Create Services to Communicate with Database
  • Create Route Controllers
    • Create a New Post Controller
    • Get a Single Post Controller
    • Get All Posts Controller
    • Update a Single Post Controller
    • Delete a Single Post Controller
  • Create Routes with Express
  • Add the Routes to the Express Middleware Pipeline
  • Run Database Migration with TypeORM

Read the entire article here: https://codevoweb.com/node-express-typeorm-postgresql-rest-api

Node.js and PostgreSQL: Upload and Resize Multiple Images

Node.js and PostgreSQL: Upload and Resize Multiple Images

In this article, you'll learn how to upload and resize single and multiple images with Node.js, TypeScript, Multer, and Sharp. The Node.js API will run on an Express.js HTTP server and use PostgreSQL database.

Topics Covered

  • Upload Single Image With Multer
    • Using Multer to Upload a Single Image
    • Route Handler Functions
  • Upload Single Image with Multer and Sharp
    • Using Multer to Upload a Single Image
    • Using Sharp to Resize a Single Image
  • Create the API Route Handlers
  • Upload Multiple Images with Multer and Sharp
    • Using Multer to Upload Multiple Images
    • Using Sharp to Resize Multiple Images
      • Processing a single file
      • Processing multiple files
    • Create the Route Functions
  • Frontend for Uploading Either Single or Multiple Images

Read the entire article here: https://codevoweb.com/node-postgresql-upload-resize-multiple-images