Book description
Build scalable web applications using Node.js, Express.js, and the latest ECMAScript techniques, along with deploying applications with AWS and Docker with this updated fifth edition
Key Features
- Learn backend web programming with the JavaScript stack
- Explore best practices, right from configuring and building web servers to deploying them on a production cloud hosting system: AWS using Docker and Terraform
- Work through the different stages of developing robust and scalable apps using Node.js 14
Book Description
Node.js is the leading choice of server-side web development platform, enabling developers to use the same tools and paradigms for both server-side and client-side software. This updated fifth edition of Node.js Web Development focuses on the new features of Node.js 14, Express 4.x, and ECMAScript, taking you through modern concepts, techniques, and best practices for using Node.js.
The book starts by helping you get to grips with the concepts of building server-side web apps with Node.js. You'll learn how to develop a complete Node.js web app, with a backend database tier to help you explore several databases. You'll deploy the app to real web servers, including a cloud hosting platform built on AWS EC2 using Terraform and Docker Swarm, while integrating other tools such as Redis and NGINX. As you advance, you'll learn about unit and functional testing, along with deploying test infrastructure using Docker. Finally, you'll discover how to harden Node.js app security, use Let's Encrypt to provision the HTTPS service, and implement several forms of app security with the help of expert practices. With each chapter, the book will help you put your knowledge into practice throughout the entire life cycle of developing a web app.
By the end of this Node.js book, you'll have gained practical Node.js web development knowledge and be able to build and deploy your own apps on a public web hosting solution.
What you will learn
- Install and use Node.js 14 and Express 4.17 for both web development and deployment
- Implement RESTful web services using the Restify framework
- Develop, test, and deploy microservices using Docker, Docker Swarm, and Node.js, on AWS EC2 using Terraform
- Get up to speed with using data storage engines such as MySQL, SQLite3, and MongoDB
- Test your web applications using unit testing with Mocha, and headless browser testing with Puppeteer
- Implement HTTPS using Let's Encrypt and enhance application security with Helmet
Who this book is for
If you're looking for an alternative to the 'P' languages (Perl, PHP, and Python), or if you want to get started with server-side web development with JavaScript programming, or if you want a deep dive into deploying services to cloud hosting, this Node.js book is for you. A rudimentary understanding of JavaScript and web application development is a must before you get started with this book.
Publisher resources
Table of contents
- Title Page
- Copyright and Credits
- Dedication
- About Packt
- Contributors
- Preface
- Section 1: Introduction to Node.js
- About Node.js
-
Setting Up Node.js
- System requirements
- Installing Node.js using package managers
- Installing from the source on POSIX-like systems
- Installing multiple Node.js instances with nvm
- Requirements for installing native code modules
- Choosing Node.js versions to use and the version policy
- Choosing editors and debuggers for Node.js
- Running and testing commands
- Advancing Node.js with ECMAScript 2015, 2016, 2017, and beyond
- Summary
-
Exploring Node.js Modules
- Defining a Node.js module
-
Finding and loading modules using require and import
- Understanding File modules
- Understanding the Node.js core modules
- Using a directory as a module
- Comparing installed packages and modules
- Finding the installed package in the file system
- Searching for globally installed packages
- Reviewing module identifiers and pathnames
- Using deep import module specifiers
- Studying an example project directory structure
- Loading modules using require, import, and import()
-
Using npm – the Node.js package management system
- The npm package format
- Accessing npm helpful documentation
- Initializing a Node.js package or project with npm init
- Finding npm packages
- Installing an npm package
- Installing a package by version number
- Installing packages from outside the npm repository
- Global package installs
- <span>Maintaining package dependencies with npm</span>
- Explicitly specifying package dependency version numbers
- Packages that install commands
- <span>Updating packages you've installed when they're outdated</span>
- Automating tasks with scripts in package.json
- Declaring Node.js version compatibility
- Publishing an npm package
- The Yarn package management system
- Summary
-
HTTP Servers and Clients
- Sending and receiving events with EventEmitter
- Understanding HTTP server applications
- HTTP Sniffer – listening to the HTTP conversation
- Web application frameworks
- Getting started with Express
- Creating an Express application to compute Fibonacci numbers
- Making HTTPClient requests
- Calling a REST backend service from an Express application
- Summary
- Section 2: Developing the Express Application
-
Your First Express Application
- Exploring Promises and async functions in Express router functions
- Architecting an Express application in the MVC paradigm
-
Creating the Notes application
- Rewriting the generated router module as an ES6 module
- Creating the Notes application wiring – app.mjs
- Implementing the Notes data storage model
- Implementing an in-memory Notes datastore
- The Notes home page
- Adding a new note – create
- Viewing notes – read
- Editing an existing note – update
- Deleting notes – destroy
- Theming your Express application
- Scaling up – running multiple Notes instances
- Summary
-
Implementing the Mobile-First Paradigm
- Understanding the problem – the Notes app isn't mobile-friendly
- Learning the mobile-first paradigm theory
- Using Twitter Bootstrap on the Notes application
- Flexbox and CSS Grids
-
Mobile-first design for the Notes application
- Laying the Bootstrap grid foundation
- Responsive page structure for the Notes application
- Using icon libraries and improving visual appeal
- Responsive page header navigation bar
- Improving the Notes list on the front page
- Cleaning up the note viewing experience
- Cleaning up the add/edit note form
- Cleaning up the delete-note window
- Customizing a Bootstrap build
- Summary
- Data Storage and Retrieval
-
Authenticating Users with a Microservice
-
Creating a user information microservice
- Developing the user information model
-
Creating a REST server for user information
- Creating a command-line tool to test and administer the user authentication server
- Creating a user in the user information database
- Reading user data from the user information service
- Updating user information in the user information service
- Deleting a user record from the user information service
- Checking the user's password in the user information service
- Providing login support for the Notes application
- Providing Twitter login support for the Notes application
- Keeping secrets and passwords secure
- Running the Notes application stack
- Summary
-
Creating a user information microservice
-
Dynamic Client/Server Interaction with Socket.IO
- Introducing Socket.IO
- Initializing Socket.IO with Express
- Real-time updates on the Notes homepage
- Inter-user chat and commenting for Notes
- Summary
- Section 3: Deployment
- Deploying Node.js Applications to Linux Servers
-
Deploying Node.js Microservices with Docker
- Setting up Docker on your laptop or computer
- Setting up the user authentication service in Docker
- Creating FrontNet for the Notes application
- Managing multiple containers with Docker Compose
- Using Redis for scaling the Notes application stack
- Summary
-
Deploying a Docker Swarm to AWS EC2 with Terraform
- Signing up with AWS and configuring the AWS CLI
- An overview of the AWS infrastructure to be deployed
- Using Terraform to create an AWS infrastructure
- Setting up a Docker Swarm cluster on AWS EC2
- Setting up ECR repositories for Notes Docker images
- Creating a Docker stack file for deployment to Docker Swarm
- Provisioning EC2 instances for a full Docker swarm
- Deploying the Notes stack file to the swarm
- Summary
-
Unit Testing and Functional Testing
- Assert <span>–</span> the basis of testing methodologies
- Testing a Notes model
- Using Docker Swarm to manage test infrastructure
- Testing REST backend services
- Automating test results reporting
- <span>Frontend headless browser testing with Puppeteer</span>
- Summary
-
Security in Node.js Applications
-
Implementing HTTPS in Docker for deployed Node.js applications
- Assigning a domain name for an application deployed on AWS EC2
- Updating the Twitter application
- Planning how to use Let's Encrypt
- Using NGINX and Let's Encrypt in Docker to implement HTTPS for Notes
- Implementing an NGINX HTTPS configuration using Let's Encrypt certificates
- Testing HTTPS support for the Notes application
-
Using Helmet for across-the-board security in Express applications
- Using Helmet to set the Content-Security-Policy header
- Using Helmet to set the X-DNS-Prefetch-Control header
- Using Helmet to control enabled browser features using the Feature-Policy header
- Using Helmet to set the X-Frame-Options header
- Using Helmet to remove the X-Powered-By header
- Improving HTTPS with Strict Transport Security
- Mitigating XSS attacks with Helmet
- Addressing Cross-Site Request Forgery (CSRF) attacks
- Denying SQL injection attacks
- Scanning for known vulnerabilities in Node.js packages
- Using good cookie practices
- Hardening the AWS EC2 deployment
- AWS EC2 security best practices
- Summary
-
Implementing HTTPS in Docker for deployed Node.js applications
- Other Books You May Enjoy
Product information
- Title: Node.js Web Development
- Author(s):
- Release date: July 2020
- Publisher(s): Packt Publishing
- ISBN: 9781838987572
You might also like
book
Node.js Web Development - Fourth Edition
Create real-time applications using Node.js 10, Docker, MySQL, MongoDB, and Socket.IO with this practical guide and …
video
Node.js - The Complete Guide
Node.js is one of the most popular and modern server-side programming languages and is used widely …
video
Node.js Essentials
6+ Hours of Video Instruction Learn to write performant back-end applications in JavaScript by leveraging the …
book
Node.js in Action, Second Edition
Node.js in Action, Second Edition is a thoroughly revised book based on the best-selling first edition. …