Node.js and Express.js Simplified

Node.js and Express.js Simplified

CodeSweetly
This is a sample of the book's content.Buy on Leanpub

Table of Contents

Node.js and Express.js Simplified

  • Introduction
    • Welcome to Node.js and Express.js!
    • What You’ll Learn
    • How You’ll Learn
    • What You Should Already Know
    • The Tools You’ll Need
    • A Personal Note
    • Let’s Begin!
  • Getting Started with Node.js
    • Install Node.js on Your System
    • Create a New Directory for Your Project
    • Create a package.json File
    • Why Node.js
    • Node’s Module Support
    • Create HTTP Servers with Node.js
    • The http.ServerResponse APIs
    • How to Run JavaScript Code on the Command Line
    • What Can You Build with Node.js?
  • File Management in Node.js
    • Types of Interfaces in the File System Module
    • Add the Callback-Based File System Module to Your Node.js App
    • Add the Promise-Based File System Module to Your Node.js App
    • Important File System Module Methods for Managing Files in Node.js
    • The node:fs Module Gives You APIs to Work with a Computer’s File System
  • File Uploads in Node.js
    • Create a New Project Directory
    • Create a package.json File
    • Create a Form for Uploading Files
    • Install the Formidable Package
    • Use the Formidable Module in Your Node.js Application
    • Run Your Application
    • What Is the Formidable parse() Method?
    • Specify Where Formidable Should Save the Uploaded Files
  • URL Management in Node.js
    • How to Use the Node.js url Module
    • URL Constructor – Parse URLs
    • fileURLToPath Function – Resolve File URLs to Paths
    • pathToFileURL Function – Resolve Paths to URLs
    • The node:url Module Provides APIs for Working with URLs
  • Serve Webpages in Node.js
    • Create a New Project Directory
    • Create the HTML Files for the Webpages You Wish to Serve
    • Configure a Web Server to Respond to Browser Requests by Serving Webpages
    • Run Your Application
  • Event Management in Node.js
    • Add the Events Module to Your Node.js Application
    • Create and Trigger Events with the EventEmitter API
    • Important Emitter Methods for Managing Events in Node.js
    • The node:events Module Provides APIs for Event Management
  • Use Express.js to Simplify HTTP Request Handling in Node
    • Create a Project Directory
    • Create a package.json File
    • Configure the Project as an ES Module Application
    • Why Express.js?
    • Raw Node.js Code vs. Express.js Code
    • Important Stuff to Know About Creating Express.js Web Servers in Node.js
  • Routes, Middleware, and Controllers in Express.js
    • Syntax of a Route in Express
    • Middleware vs. Route Handler
    • Examples
    • Important Things to Know about the next Parameter
    • Categories of Middleware in Express.js
  • Route vs. Query Parameters in Express.js
    • Create a New Project Directory
    • Create a package.json File
    • Configure the Project as an ES Module Application
    • Install Express
    • Configure a Web Server to Respond to Browser Requests
    • What Is a Query Parameter in Express?
    • What Is a Route Parameter in Express?
  • Router in Express.js
    • Create a New Project Directory
    • Create a package.json File
    • Configure the Project as an ES Module Application
    • Install Express
    • Group Related Routes and Middleware
    • Configure the Main Express Application
    • Run Your Express.js Application
    • Important Things to Know about Express Routers
  • Views in Express.js
    • Create a New Project Directory
    • Create a package.json File
    • Configure the Project as an ES Module Application
    • Install Express
    • Types of Views in Express.js
    • What Are Static Views in Express.js?
    • What Are Dynamic Views in Express.js?
  • Handling Form Data in Express.js
    • Validation vs Sanitization vs Output Escaping: What’s the Difference?
    • Types of Form Validation
    • What Is Client-Side Form Validation?
    • What Is Server-Side Form Validation?
    • How to Use Express-Validator to Validate a Form’s Data
    • Important Things to Know About Validation, Sanitization, and Output Escaping in Express
    • POST vs GET Method Attributes in HTML Forms
  • Connect a Frontend Application to a Node.js Backend
    • Create a New Project Directory
    • Create the Frontend and Backend Project Directories
    • Configure the Project’s Backend
    • Configure the Project’s Frontend
    • Configure CORS in the Backend
    • Run Your Full-Stack Application
    • Send Data from the Frontend to the Express Backend
    • Use express.json() to Parse a JSON Request Body
  • Deploy a Full-Stack Application
    • Deploy Your Backend Application to Render
    • Deploy Your Frontend Application to Vercel
  • Manage User Sessions in Express with Express-Session
    • Create a Basic Express Application
    • Inspect Your App’s Cookies in the Browser
    • Add Session Support with express-session
    • Understand the Three Session-Related Properties
    • Explore the Session Properties in Action
  • Test Express HTTP Endpoints with Supertest and node:test
    • What’s the Difference Between a Test Runner and an HTTP Testing Tool?
    • Create a Project Directory
    • Create a package.json File
    • Configure the Project as an ES Module Application
    • Install Express
    • Install the HTTP Testing Library
    • Test HTTP Requests
    • Run the App Script
    • Use the node:test Module to Run Tests
    • Configure the App’s Web Server
    • Run the Express.js Web Server
    • Important Things to Know about Testing HTTP Endpoints
  • Use TypeScript with Express.js
    • Create a Project Directory
    • Create a package.json File
    • Configure the Project as an ES Module Application
    • Install Express
    • Install TypeScript and Type Definitions
    • Configure a Web Server to Respond to Browser Requests
    • Run the Express Web Server
  • Add ESLint to an Express Application
    • Initialize ESLint’s Configuration
    • Lint Your Code
    • Customize ESLint Rules
    • Specify the Files ESLint Should Ignore
  • Epilogue
    • What Next?
    • Keep Growing
    • One Last Favor
    • Final Words
Node.js and Express.js Simplified/File Management in Node.js

File Management in Node.js

https://leanpub.com/node-and-express-simplified

Types of Interfaces in the File System Module

https://leanpub.com/node-and-express-simplified

Add the Callback-Based File System Module to Your Node.js App

https://leanpub.com/node-and-express-simplified

Add the Promise-Based File System Module to Your Node.js App

https://leanpub.com/node-and-express-simplified

Important File System Module Methods for Managing Files in Node.js

https://leanpub.com/node-and-express-simplified

fs.writeFile() – Write data to a file

https://leanpub.com/node-and-express-simplified

fs.readFile() – Read a file’s content

https://leanpub.com/node-and-express-simplified

fs.appendFile() – Append data to a file

https://leanpub.com/node-and-express-simplified

fs.rename() – Rename a file or folder

https://leanpub.com/node-and-express-simplified

fs.unlink() – Delete a file or symbolic link

https://leanpub.com/node-and-express-simplified

The node:fs Module Gives You APIs to Work with a Computer’s File System

https://leanpub.com/node-and-express-simplified

Previous

Getting Started with Node.js

Up next

File Uploads in Node.js

In this chapter

  • File Management in Node.js
  • Types of Interfaces in the File System Module
  • Add the Callback-Based File System Module to Your Node.js App
  • Add the Promise-Based File System Module to Your Node.js App
  • Important File System Module Methods for Managing Files in Node.js
  • The node:fs Module Gives You APIs to Work with a Computer’s File System