Backend Full Course | NodeJS ExpressJS PostgreSQL Prisma & Docker

Share

Summary

This comprehensive Backend Full Course takes you from a beginner to a pro in backend development. It covers core concepts, best practices, and the latest technologies like NodeJS, ExpressJS, PostgreSQL, Prisma, and Docker. The course is structured into four chapters, building increasingly complex applications, culminating in a Dockerized full-stack application with JWT authentication and a PostgreSQL database.

Highlights

Introduction to Backend Development Course
00:00:01

James introduces a comprehensive backend development course aimed at beginners to turn them into pros. The course focuses on three key aspects: beginner-friendliness, teaching core concepts and best practices, and building a portfolio of hire-worthy projects. It's structured into four chapters, starting with theory and progressing through practical projects.

Understanding the Internet: Full Stack, Frontend, and Backend
00:05:22

Chapter 1 explains the fundamental concepts of how the internet works, including the 'full stack' as the culmination of programming components for user experience. It differentiates between the 'frontend' (user-facing, client-side, browser-based HTML, CSS, JavaScript) and the 'backend' (server-side, handling requests, data, and services over a network). The process of a network request, from URL to server response, is detailed.

Chapter 2: First Practical Backend Application - Basic Server Setup
00:17:42

Chapter 2 begins the practical introduction to backend development. It covers essential tools like VS Code, Node.js, and Docker. The instructor walks through setting up a Node.js project using npm, installing the Express.js framework, and creating a basic server that listens for incoming requests on a specified port. The importance of `package.json` for project specifications and dependencies is highlighted, along with the use of Nodemon for automatic server restarts during development.

Handling Network Requests: HTTP Verbs and Routes
00:41:48

This section explains how to configure the Express.js server to handle incoming network requests. It introduces HTTP verbs (GET, POST, PUT, DELETE, corresponding to CRUD operations) and routes (or paths). The server is configured to respond to GET requests on the root ('/') and '/dashboard' routes, demonstrating how to send back basic HTML. The usage of a REST client extension for testing API endpoints is introduced, along with HTTP status codes for responses.

Building a Dynamic Web Server and Data Interaction
01:03:00

The course progresses to making the server more dynamic. HTML code can be sent back as a response, integrating data dynamically. The distinction between website endpoints (serving HTML) and API endpoints (sending data like JSON) is made. A basic data object is created, and the server is set up to respond with this data to an API endpoint. POST (create) and DELETE requests are implemented, demonstrating how to add and remove data entries, and the concept of middleware for processing requests is briefly touched upon.

Chapter 3: Advanced Backend Application with SQLite Database and JWT Authentication
01:34:05

Chapter 3 focuses on building a more comprehensive backend application. Key topics include upgrading Node.js versions using NVM (Node Version Manager) to access experimental features like SQLite database integration. The project structure is refined with dedicated folders for middleware, routes, database logic, and public assets. NPM packages like Express.js, bcrypt.js (for password hashing), and jsonwebtoken (for JWT authentication) are installed. The server is configured with updated import syntax and environment variables.

Serving Frontend and Database Setup with SQLite
02:02:11

The application is set up to serve a pre-built frontend (HTML, CSS, JavaScript) from a `public` directory, enabling a full-stack experience. The video explains how to configure Express.js to serve static files and handle incoming JSON data. The SQLite database is initialized as an in-memory database, and SQL commands are used to create 'users' and 'todos' tables, establishing relationships between them through primary and foreign keys. The importance of clean project structure and modular code is emphasized.

Implementing User Registration with Secure Passwords and Default To-Do
02:29:40

The implementation of the user registration endpoint is detailed. Security best practices are introduced, including hashing passwords using bcrypt.js to prevent data breaches. The server receives user credentials, hashes the password, inserts the new user into the database, and assigns a default to-do item. A JSON Web Token (JWT) is generated upon successful registration, which is then sent back to the client for future authentication. Error handling with try-catch blocks is also covered.

User Login and Authentication Middleware
03:18:11

The user login endpoint is developed, focusing on authenticating existing users. The server retrieves the hashed password from the database, compares it with the provided password using bcrypt.js, and generates a JWT upon successful authentication. Crucially, the concept of authentication middleware is introduced. This middleware intercepts network requests, verifies the JWT, and adds the user's ID to the request object before it reaches the intended endpoint, ensuring that only authenticated users can access protected resources (like to-do list operations).

Implementing To-Do CRUD Operations
03:47:30

The CRUD (Create, Read, Update, Delete) operations for to-do items are implemented. The 'get all to-dos' endpoint queries the database for to-dos associated with the authenticated user ID. The 'create to-do' endpoint receives a task, inserts it into the database, and returns the new to-do. The 'update to-do' endpoint uses dynamic parameters in the route to identify a specific to-do by ID and updates its 'completed' status. Finally, the 'delete to-do' endpoint removes an item from the database based on its ID and the user ID.

Chapter 4: Dockerizing the Backend with PostgreSQL and Prisma ORM
04:16:25

Chapter 4 elevates the backend application to an enterprise-level, production-ready system. It begins by migrating from SQLite to PostgreSQL, a more robust SQL database. Instead of direct SQL queries, the Prisma ORM (Object-Relational Mapper) is integrated to interact with the database using a JavaScript-like syntax. The project is then 'Dockerized,' creating separate Docker containers for the Node.js application and the PostgreSQL database, enabling isolated and scalable environments.

Docker, Prisma Schema, and Database Migrations
04:39:15

The process of Dockerizing the application is detailed, including creating a `Dockerfile` to build the Node.js application's image. This instruction sheet defines the base Node.js image, sets the working directory, copies `package.json` for dependency installation, copies the rest of the application code, exposes a port, and defines the startup command. The Prisma schema is configured to define the structure of the PostgreSQL 'user' and 'todo' tables, including relationships and default values. The concept of database migrations with Prisma is explained, allowing for controlled evolution of the database schema.

Docker Compose and Running the Full Stack
04:53:32

A `docker-compose.yaml` file is created to orchestrate the multi-container application. This file defines two services: 'app' (the Node.js backend) and 'database' (PostgreSQL). It specifies build commands, container names, environment variables (including the PostgreSQL connection URL and JWT secret), port mappings, and volume persistence for data. The video then guides through building the Docker images, running Prisma migrations to set up the database tables, and finally using `docker compose up` to launch both containers as a cohesive application. The functionality of the complete Dockerized full-stack application, including user registration, login, and to-do CRUD operations, is demonstrated.

Recently Summarized Articles

Loading...