Node.js - The Complete Guide

Video description

Master Node JS and Deno.js, build REST APIs with Node.js, explore GraphQL APIs, add authentication, use MongoDB and SQL, and learn much more with this complete course

About This Video

  • Get to grips with the basic as well as advanced concepts of NodeJS
  • Build modern, fast, and scalable server-side web applications with Node.js databases
  • Understand the Node.js ecosystem and build server-side rendered apps, REST APIs, and GraphQL APIs

In Detail

Node.js is one of the most popular and modern server-side programming languages and is used widely from traditional web apps with server-side rendered views over REST APIs to GraphQL APIs and real-time web services. With the high demand for Node.js developers in the job market, now is the time to develop Node.js skills. This updated video course will teach you all that you need from scratch.

The course begins with an introduction to Node.js and a quick refresher on JavaScript. You’ll then understand the improved development workflow and debugging, get to grips with Express.js, and work with dynamic content and add template engines. As you progress, you’ll work with the model view controller (MVC) to develop user interfaces and learn the dynamic route and advanced models. The course will also take you through using Node.js with SQL, NoSQL, and Mongoose and help you gain a solid understanding of implementing authentication, sending emails, error handling, validation, file uploading and downloading, and pagination. Finally, you’ll work with REST and GraphQL APIs, DenoJS, build a real-time Node.js app with WebSockets, perform automation testing, and deploy a Node.js application.

By the end of this course, you’ll have developed the Node.js skills needed to build robust, scalable, and powerful web applications.

Who this book is for

This updated course is for the beginners as well as experienced web developers looking to learn backend (server-side) development with Node.js. If you are interested in building modern, scalable, and high-performing web applications or want to explore updated features such as modern JavaScript, Typescript, GraphQL, and DenoJS, you’ll find this course useful. Basic knowledge of JavaScript is needed to get started with this course.

Publisher resources

Download Example Code

Table of contents

  1. Chapter 1 : Introduction
    1. Introduction
    2. What is Node.js?
    3. Installing Node.js and Creating your First App
    4. Understanding the Role and Usage of Node.js
    5. Course Outline
    6. How to Get the Most Out of the Course?
    7. Working with the Read-Eval-Print Loop (REPL) vs Using Files
  2. Chapter 2 : Optional: JavaScript - A Quick Refresher
    1. Module Introduction
    2. JavaScript in a Nutshell
    3. Refreshing the Core Syntax
    4. Let and Const
    5. Understanding Arrow Functions
    6. Working with Objects, Properties, and Methods
    7. Arrays and Array Methods
    8. Arrays, Objects, and Reference Types
    9. Understanding Spread and Rest Operators
    10. Destructuring
    11. Async Code and Promises
    12. Wrap up
  3. Chapter 3 : Understanding the Basics
    1. Module Introduction
    2. How the Web Works?
    3. Creating a Node Server
    4. The Node Lifecycle and Event Loop
    5. Understanding Requests
    6. Sending Responses
    7. Routing Requests
    8. Redirecting Requests
    9. Parsing Request Bodies
    10. Understanding Event Driven Code Execution
    11. Blocking and Non-Blocking Code
    12. Node.js - Looking Behind the Scenes
    13. Using the Node Modules System
    14. Wrap Up
  4. Chapter 4 : Improved Development Workflow and Debugging
    1. Module Introduction
    2. Understanding Node Package Manager (NPM) Scripts
    3. Installing Third Party Packages
    4. Using Nodemon for Auto Restarts
    5. Understanding Different Error Types
    6. Finding and Fixing Syntax Errors
    7. Dealing with Runtime Errors
    8. Logical Errors
    9. Using the Debugger
    10. Restarting the Debugger Automatically After Editing your App
    11. Changing Variables in the Debug Console
    12. Wrap Up
  5. Chapter 5 : Working with Express.js
    1. Module Introduction
    2. What is Express.js?
    3. Installing Express.js
    4. Adding Middleware
    5. How Middleware Works?
    6. Express.js - Looking Behind the Scenes
    7. Handling Different Routes
    8. Parsing Incoming Requests
    9. Limiting Middleware Execution to POST Requests
    10. Using Express Router
    11. Adding a 404 Error Page
    12. Filtering Paths
    13. Creating HTML Pages
    14. Serving HTML Pages
    15. Returning a 404 Page
    16. Using a Helper Function for Navigation
    17. Styling your Pages
    18. Serving Files Statically
    19. Wrap Up
  6. Chapter 6 : Working with Dynamic Content and Adding Templating Engines
    1. Module Introduction
    2. Sharing Data across Requests and Users
    3. Templating Engines - An Overview
    4. Installing and Implementing Pug
    5. Outputting Dynamic Content
    6. Converting HTML Files to Pug
    7. Adding a Layout
    8. Finishing the Pug Template
    9. Working with Handlebars
    10. Converting your Project to Handlebars
    11. Adding a Layout to Handlebars
    12. Working with Embedded JavaScript Templating (EJS)
    13. Working on the Layout with Partials
    14. Wrap Up
  7. Chapter 7 : The Model View Controller (MVC)
    1. Module Introduction
    2. What is Model View Controller (MVC)?
    3. Adding Controllers
    4. Finishing the Controllers
    5. Adding a Product Model
    6. Storing Data in Files through the Model
    7. Fetching Data from Files through the Model
    8. Refactoring the File Storage Code
    9. Wrap Up
  8. Chapter 8 : Optional: Enhancing the App
    1. Module Introduction
    2. Creating the Shop Structure
    3. Working of the Navigation System
    4. Registering the Routes
    5. Storing Product Data
    6. Displaying Product Data
    7. Editing and Deleting Products
    8. Adding Another Item
  9. Chapter 9 : Dynamic Routes and Advanced Models
    1. Module Introduction
    2. Preparations
    3. Adding the Product ID to the Path
    4. Extracting Dynamic Params
    5. Loading Product Detail Data
    6. Rendering the Product Detail View
    7. Passing Data with POST Requests
    8. Adding a Cart Model
    9. Using queryParams
    10. Pre-Populating the Edit Product Page with Data
    11. Linking to the Edit Page
    12. Editing the Product Data
    13. Adding the Delete Functionality for a Product
    14. Deleting Cart Items
    15. Displaying Cart Items on the Cart Page
    16. Deleting Cart Items
    17. Fixing a Delete Product Bug
    18. Wrap Up
  10. Chapter 10 : SQL Introduction
    1. Module Introduction
    2. Choosing a Database
    3. NoSQL Introduction
    4. Comparing SQL and NoSQL
    5. Setting up MySQL
    6. Connecting the App to the SQL Database
    7. Basic SQL and Creating a Table
    8. Retrieving Data
    9. Fetching Products
    10. Fetching Products - Time to Practice
    11. Inserting Data into the Database
    12. Fetching a Single Product with the "WHERE" Clause
    13. Wrap Up
  11. Chapter 11 : Understanding Sequelize
    1. Module Introduction
    2. What is Sequelize?
    3. Connecting to the Database
    4. Defining a Model
    5. Syncing JavaScript Definitions to the Database
    6. Inserting Data and Creating a Product
    7. Retrieving Data and Finding Products
    8. Fetching a Single Product with the "WHERE" clause
    9. Fetching Admin Products
    10. Updating Products
    11. Deleting Products
    12. Creating a User Model
    13. Adding a One-To-Many Relationship
    14. Creating and Managing a Dummy User
    15. Using Magic Association Methods
    16. Fetching Related Products
    17. One-To-Many and Many-To-Many Relations
    18. Creating and Fetching a Cart
    19. Adding New Products to the Cart
    20. Adding Existing Products and Retrieving Cart Items
    21. Deleting Related Items and Deleting Cart Products
    22. Adding an Order Model
    23. Storing Cart items as Order items
    24. Resetting the Cart and Fetching and Outputting Orders
    25. Wrap Up
  12. Chapter 12 : Working with NoSQL and Using MongoDB
    1. Module Introduction
    2. What is MongoDB?
    3. Relations in NoSQL
    4. Setting up MongoDB
    5. Installing the MongoDB Driver
    6. Creating the Database Connection
    7. Finishing the Database Connection
    8. Using the Database Connection
    9. Creating Products
    10. Understanding the MongoDB Compass
    11. Fetching All Products
    12. Fetching a Single Product
    13. Making the "Edit" "Delete" Buttons Work Again
    14. Working on the Product Model to Edit the Product
    15. Finishing the "Update Product" Code
    16. Important Note on Updating Products
    17. Deleting Products
    18. Fixing the "Add Product" Functionality
    19. Creating New Users
    20. Storing the User in the Database
    21. Working on Cart Items and Orders
    22. Adding the "Add to Cart" Functionality
    23. Storing Multiple Products in the Cart
    24. Displaying the Cart Items
    25. Fixing a Bug
    26. Deleting Cart Items
    27. Adding an Order
    28. Adding Relational Order Data
    29. Getting Orders
    30. Removing Deleted Items from the Cart
    31. Wrap Up
  13. Chapter 13 : Working with Mongoose
    1. Module Introduction
    2. What is Mongoose?
    3. Connecting to the MongoDB Server with Mongoose
    4. Creating the Product Schema
    5. Saving Data through Mongoose
    6. Fetching all Products
    7. Fetching a Single Product
    8. Updating Products
    9. Deleting Products
    10. Adding and Using a User Model
    11. Using Relations in Mongoose
    12. Important Thing about Fetching Relations
    13. Working on the Shopping Cart
    14. Loading the Cart
    15. Deleting Cart Items
    16. Creating and Getting Orders
    17. Storing all Order Related Data
    18. Clearing the Cart after Storing an Order
    19. Getting and Displaying the Orders
    20. Wrap Up
  14. Chapter 14 : Sessions and Cookies
    1. Module Introduction
    2. What is a Cookie?
    3. The Current Project Status
    4. Optional: Creating the Login Form
    5. Adding a Request-Driven Login Solution
    6. Setting a Cookie
    7. Manipulating Cookies
    8. Configuring Cookies
    9. What is a Session?
    10. Initializing the Session Middleware
    11. Using the Session Middleware
    12. Using MongoDB to Store Sessions
    13. Sessions and Cookies - A Short Summary
    14. Deleting a Cookie
    15. Fixing Some Minor Bugs
    16. Making "Add to Cart" Work Again
    17. Two Tiny Improvements
    18. Wrap Up
  15. Chapter 15 : Adding Authentication
    1. Module Introduction
    2. What is Authentication?
    3. How is Authentication Implemented?
    4. Updated Project Status
    5. Implementing an Authentication Flow
    6. Encrypting Passwords
    7. Adding a Tiny Code Improvement
    8. Adding the Sign in Functionality
    9. Working on Route Protection
    10. Using Middleware to Protect Routes
    11. Understanding Cross-Site Request Forgery (CSRF) Attacks
    12. Using a Cross-Site Request Forgery (CSRF) Token
    13. Adding Cross-Site Request Forgery (CSRF) Protection
    14. Fixing the Order Button
    15. Providing User Feedback
    16. Optional: Styling Error Messages
    17. Finishing the Flash Messages
    18. Adding Additional Flash Messages
    19. Wrap Up
  16. Chapter 16 : Sending Emails
    1. Module Introduction
    2. How Does Sending Emails Work?
    3. Using SendGrid
    4. Using Nodemailer to Send an Email
    5. Potential Limitation for Large Scale Apps
  17. Chapter 17 : Advanced Authentication
    1. Module Introduction
    2. Resetting Passwords
    3. Implementing the Token Logic
    4. Creating the Token
    5. Creating the Reset Password Form
    6. Adding Logic to Update the Password
    7. Why we Need Authorization?
    8. Adding Authorization
    9. Adding Protection to Post Actions
    10. Why Editing Fails?
    11. Wrap Up
  18. Chapter 18 : Understanding Validation
    1. Module Introduction
    2. Why Should we use Validation?
    3. How to Validate Input?
    4. Setup Basic Validation
    5. Using Validation Error Messages
    6. Built-In Custom Validators
    7. More Validators
    8. Checking for Field Equality
    9. Adding Async Validation
    10. Keeping User Input
    11. Adding Conditional CSS Classes
    12. Adding Validation to Login
    13. Sanitizing Data
    14. Validating Product Addition
    15. Validating Product Editing
    16. Wrap Up
  19. Chapter 19 : Error Handling
    1. Module Introduction
    2. Types of Errors and Error Handling
    3. Analyzing Error Handling in the Current Project
    4. Errors - Some Theory
    5. Throwing Errors in Code
    6. Returning Error Pages
    7. Using the Express.js Error Handling Middleware
    8. Updating the App
    9. Using the Error Handling Middleware Correctly
    10. Status Codes
    11. Wrap Up
  20. Chapter 20 : File Upload and Download
    1. Module Introduction
    2. Adding a File Picker to the Frontend
    3. Handling Multipart Form Data
    4. Handling File Uploads with Multer
    5. Configuring Multer to Adjust Filename and File Path
    6. Filtering Files by MIME type
    7. Storing File Data in the Database
    8. Serving Images Statically
    9. Downloading Files with Authentication
    10. Setting Up File Type Headers
    11. Restricting File Access
    12. Streaming Data vs Preloading Data
    13. Using PDFKit for .pdf Generation
    14. Generating .pdf Files with Order Data
    15. Deleting Files
    16. Fixing Invoice Links
    17. Wrap Up
  21. Chapter 21 : Adding Pagination
    1. Module Introduction
    2. Adding Pagination Links
    3. Retrieving a Chunk of Data
    4. Preparing Pagination Data on the Server
    5. Adding Dynamic Pagination Buttons
    6. Re-using the Pagination Logic and Controls
    7. Wrap Up
  22. Chapter 22 : Understanding Async Requests
    1. Module Introduction
    2. What are Async Requests?
    3. Adding Client Side JavaScript Code
    4. Sending and Handling Background Requests
    5. Manipulating the Document Object Model (DOM)
  23. Chapter 23 : Adding Payments
    1. Module Introduction
    2. How Payments Work?
    3. Adding a Checkout Page
    4. Using Stripe in Your App
  24. Chapter 24 : Working with REST APIs - The Basics
    1. Module Introduction
    2. What Are REST APIs and Why Do We Use Them?
    3. Accessing Data with REST APIs
    4. Understanding Routing and HTTP Methods
    5. REST APIs - The Core Principles
    6. Creating our REST API Project and Implementing the Route Setup
    7. Sending Requests and Responses and Working with Postman
    8. REST APIs, Clients, and Cross-Origin Resource Sharing (CORS) Errors
    9. Sending POST Requests
    10. Wrap Up
  25. Chapter 25 : Working with REST APIs - The Practical Application
    1. Module Introduction
    2. REST APIs and the Rest of the Course
    3. Understanding the Frontend Setup
    4. Planning the API
    5. Fetching Lists of Posts
    6. Adding a Create Post Endpoint
    7. Adding Server-Side Validation
    8. Setting up a Post Model
    9. Storing Posts in the Database
    10. Static Images and Error Handling
    11. Fetching a Single Post
    12. Uploading Images
    13. Updating Posts
    14. Deleting Posts
    15. Adding Pagination
    16. Adding a User Model
    17. Adding User Signup Validation
    18. Signing Users up
    19. How Does Authentication Work?
    20. Starting with User Login
    21. Log in and Creating JSON Web Tokens (JWTs)
    22. Using and Validating the Token
    23. Adding Auth Middleware to all Routes
    24. Connecting Posts and Users
    25. Adding Authorization Checks
    26. Clearing Post-User Relations
    27. Wrap Up
  26. Chapter 26 : Understanding Async/Await in Node.js
    1. Module Introduction
    2. What is Async/Await all About?
    3. Transforming "Then/Catch" to "Async/Await"
    4. Wrap Up
  27. Chapter 27 : Understanding WebSocket Socket.io
    1. Module Introduction
    2. What Are WebSocket and Why Would You Use Them?
    3. WebSocket Solutions - An Overview
    4. Setting up Socket.io on the Server
    5. Establishing a Connection from the Client
    6. Identifying Realtime Potential
    7. Sharing the IO Instance Across Files
    8. Synchronizing POST Additions
    9. Fixing a Bug - The Missing Username
    10. Updating Posts on all Connected Clients
    11. Sorting Correctly
    12. Deleting Posts across Clients
    13. Wrap Up
  28. Chapter 28 : Working with GraphQL
    1. Module Introduction
    2. What is GraphQL?
    3. Understanding the Setup and Writing First Query
    4. Defining a Mutation Schema
    5. Adding a Mutation Resolver and GraphQL
    6. Adding Input Validation
    7. Handling Errors
    8. Connecting the Frontend to the GraphQL API
    9. Adding a Login Query and a Resolver
    10. Adding Login Functionality
    11. Adding a "Create Post" Mutation
    12. Extracting User Data from the Auth Token
    13. Sending the "Create Post" Query
    14. Fixing a Bug and Adding New Posts Correctly
    15. Adding a "Get Post" Query and Resolver
    16. Sending "Create Post" and "Get Post" Queries
    17. Adding Pagination
    18. Uploading Images
    19. Viewing a Single Post
    20. Updating Posts
    21. Deleting Posts
    22. Managing the User Status
    23. Using Variables
    24. Fixing a Pagination Bug
    25. Wrap Up
  29. Chapter 29 : Deploying the App
    1. Module Introduction
    2. Deploying Different Kinds of Apps
    3. Deployment Preparations
    4. Using Environment Variables
    5. Using Production API Keys
    6. Setting Secure Response Headers with Helmet
    7. Compressing Assets
    8. Setting up Request Logging
    9. Setting up a Secure Sockets Layer (SSL) Server
    10. Using a Hosting Provider
    11. Understanding the Project and the Git Setup
    12. A Deployment Example with Heroku
    13. Deploying APIs
  30. Chapter 30 : Testing Node.js Applications
    1. Module Introduction
    2. What is Testing?
    3. Testing - Why and How?
    4. Setup and Writing the First Test
    5. Testing the Auth Middleware
    6. Organizing Multiple Tests
    7. What Not to Test!
    8. Using Stubs
    9. Testing Controllers
    10. Testing Asynchronous Code
    11. Setting up a Testing Database
    12. Testing Code with an Active Database
    13. Cleaning Up
    14. Hooks
    15. Testing Code That Requires Authentication
    16. Wrap up and Mastering Tests
  31. Chapter 31 : Node.js as a Build Tool and Using NPM
    1. Module Introduction
    2. NPM and Node.js
    3. Using NPM
    4. What is a Build Tool?
    5. Using Node.js in Build Processes
  32. Chapter 32 : Modern JavaScript and Node.js
    1. Module Introduction
    2. What is this Module About?
    3. Working with ECMAScript Modules (ES Modules) and Node
    4. More on ECMAScript Modules (ES Modules)
    5. Node Core Modules and Promises
  33. Chapter 33 : Node.js and TypeScript
    1. Module Introduction
    2. TypeScript: What and Why?
    3. TypeScript Setup
    4. Assigning Types
    5. Type Inference and Type Casting
    6. Configuring TypeScript
    7. Working with Union Types
    8. Using Object and Array Types
    9. Working with Type Aliases and Interfaces
    10. Understanding Generics
    11. A First Summary
    12. Node and TypeScript: Setup
    13. Getting Started with Node and TypeScript
    14. Writing TypeScript Express.js Code
    15. Adding REST Routes with TypeScript
    16. Finishing the REST Routes
    17. Testing the API
    18. Using Type Casting
    19. Moving to a Better Project Structure
    20. Wrap Up
  34. Chapter 34 : An Introduction to Deno
    1. Module Introduction
    2. What is Deno?
    3. Why Deno?
    4. Deno Setup
    5. Writing First Deno Code
    6. The Deno Runtime (Namespace) API
    7. Using the Runtime API
    8. Working with Deno Permissions
    9. Repeating the Example with Node
    10. How Deno Features Are Organized
    11. Using the Standard Library
    12. Creating a Webserver
    13. Using the Oak Framework with Deno
    14. An Example Node REST API
    15. Re-building the REST API with Deno
    16. Should You Switch from Node to Deno?
  35. Chapter 35 : Deno, CRUD and Databases (MongoDB)
    1. Module Introduction
    2. App Setup
    3. Handling CORS Errors
    4. Connecting Deno to MongoDB
    5. Using the MongoDB Client Module
    6. Finishing the Deno MongoDB CRUD Operations
    7. Wrap Up
  36. Chapter 36 : Roundup
    1. Course Roundup

Product information

  • Title: Node.js - The Complete Guide
  • Author(s): Academind by Maximilian Schwarzmüller
  • Release date: April 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781838826864