Node.js Web Development - Third Edition
eBook - ePub

Node.js Web Development - Third Edition

  1. 376 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Node.js Web Development - Third Edition

About this book

Create real-time server-side applications with this practical, step-by-step guideAbout This Book• Learn about server-side JavaScript with Node.js and Node modules through the most up-to-date book on Node.js web development• Understand website development both with and without the Connect/Express web application framework• Develop both HTTP server and client applicationsWho This Book Is ForThis book is for anybody looking for an alternative to the "P" languages (Perl, PHP, and Python), or anyone looking for a new paradigm of server-side application development. You should have at least a rudimentary understanding of JavaScript and web application development.What You Will Learn• Install and use Node.js for both development and deployment• Use the Express application framework• Configure Bootstrap for mobile-first theming• Use data storage engines such as MySQL, SQLITE3, and MongoDB• Understand user authentication methods, including OAuth, with third-party services• Deploy Node.js to live servers, including microservice development with Docker• Perform unit testing with Mocha• Perform functional testing of the web application with CasperJSIn DetailNode.js is a server-side JavaScript platform using an event driven, non-blocking I/O model allowing users to build fast and scalable data-intensive applications running in real time. Node.js Web Development shows JavaScript is not just for browser-side applications. It can be used for server-side web application development, real-time applications, microservices, and much more.This book gives you an excellent starting point, bringing you straight to the heart of developing web applications with Node.js. You will progress from a rudimentary knowledge of JavaScript and server-side development to being able to create and maintain your own Node.js application. With this book you'll learn how to use the HTTP Server and Client objects, data storage with both SQL and MongoDB databases, real-time applications with Socket.IO, mobile-first theming with Bootstrap, microservice deployment with Docker, authenticating against third-party services using OAuth, and much more.Style and ApproachThis book is a practical guide for anyone looking to develop striking and robust web applications using Node.js.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Node.js Web Development Third Edition


Table of Contents

Node.js Web Development Third Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. About Node.js
The capabilities of Node.js
Server-side JavaScript
Why should you use Node.js?
Popularity
JavaScript at all levels of the stack
Leveraging Google's investment in V8
Leaner asynchronous event-driven model
Microservice architecture
The Node.js is stronger for having survived a major schism and hostile fork
Performance and utilization
Is Node.js a cancerous scalability disaster?
Server utilization, the bottom line, and green web hosting
Node.js, the microservice architecture, and easily testable systems
Node.js and the Twelve-Factor app model
Summary
2. Setting up Node.js
System requirements
Installing Node.js using package managers
Installing on Mac OS X with MacPorts
Installing on Mac OS X with Homebrew
Installing on Linux, *BSD, or Windows from package management systems
Installing the Node.js distribution from nodejs.org
Installing from source on POSIX-like systems
Installing prerequisites
Native code modules and node-gyp
Installing developer tools on Mac OS X
Installing from source for all POSIX-like systems
Installing development instances with nvm
Node.js versions policy and what to use
Running and testing commands
Node.js's command-line tools
Running a simple script with Node.js
Launching a server with Node.js
NPM – the Node.js package manager
Node.js and ECMAScript 6 (ES-2015, ES-2016, and so on)
Using Babel to use experimental JavaScript features
Summary
3. Node.js Modules
Defining a module
Node.js module format
File modules
Demonstrating module-level encapsulation
Directories as modules
Node.js's algorithm for require (module)
Module identifiers and path names
An example application directory structure
npm – the Node.js package management system
The npm package format
Finding npm packages
Other npm commands
Installing an npm package
Initializing a new npm package
Maintaining package dependencies with npm
Fixing bugs by updating package dependencies
Declaring Node.js version compatibility
Updating outdated packages you've installed
Installing packages from outside the npm repository
Publishing an npm package
Package version numbers
A quick note about CommonJS
Summary
4. HTTP Servers and Clients – A Web Application's First Steps
Sending and receiving events with EventEmitters
The EventEmitter theory
HTTP server applications
ES-2015 multiline and template strings
HTTP Sniffer – listening to the HTTP conversation
Web application frameworks
Getting started with Express
Walking through the default Express application
The Express middleware
Middleware and request paths
Error handling
Calculating the Fibonacci sequence with an Express application
Computationally intensive code and the Node.js event loop
Algorithmic refactoring
Making HTTP Client requests
Calling a REST backend service from an Express application
Implementing a simple REST server with Express
Refactoring the Fibonacci application for REST
Some RESTful modules and frameworks
Summary
5. Your First Express Application
ES-2015 Promises and Express router functions
Promises and error handling
Flattening our asynchronous code
Additional tools
Express and the MVC paradigm
Creating the Notes application
Your first Notes model
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
6. Implementing the Mobile-First Paradigm
Problem – the Notes app isn't mobile friendly
Mobile-first paradigm
Using Twitter Bootstrap on the Notes application
Setting it up
Adding Bootstrap to application templates
Mobile-first design for the Notes application
Laying the Bootstrap grid foundation
Improving the notes list on the front page
Breadcrumbs for the page header
Cleaning up the add/edit note form
Building a customized Bootstrap
Bootstrap customizers
Summary
7. Data Storage and Retrieval
Data storage and asynchronous code
Logging
Request logging with Morgan
Debugging messages
Capturing stdout and stderr
Uncaught exceptions
Storing notes in the filesystem
Storing notes with the LevelUP data store
Storing notes in SQL with SQLite3
SQLite3 database scheme
SQLite3 model code
Running Notes with SQLite3
Storing notes the ORM way with Sequelize
Sequelize model for the Notes application
Configuring a Sequelize database connection
Running the Notes application with Sequelize
Storing notes in MongoDB
MongoDB model for the Notes application
Running the Notes application with MongoDB
Summary
8. Multiuser Authentication the Microservice Way
Creating a user information microservice
User information model
A REST server for user information
Scripts to test and administer the User Authentication server
Login support for the Notes application
Accessing the user authentication REST API
Login and logout routing functions
Login/logout changes to app.js
Login/logout changes in routes/index.js
Login/logout changes required in routes/notes.js
View template changes supporting login/logout
Running the Notes application with user authentication
Twitter login support for the Notes application
Registering an application with Twitter
Implementing TwitterStrategy
The Notes application stack
Summary
9. Dynamic Interaction between Client and Server with Socket.IO
Introducing Socket.IO
Initializing Socket.IO with Express
Real time updates on the Notes home page
The Notes model as an EventEmitter class
Real-time changes in the Notes home page
Changing the home page template
Running Notes with real-time home page updates
Real-time action while viewing notes
Changing the note view template for real-time action
Running Notes with real-time updates while viewing a note
Inter-user chat and commenting for Notes
Data model for storing messages
Adding messages to the Notes router
Changing the note view template for messages
Using a Modal window to compose messages
Sending, displaying, and deleting messages
Running Notes and passing messages
Other applications of Modal windows
Summary
10. Deploying Node.js Applications
Notes application architecture
Traditional Linux Node.js service deployment
Prerequisite – provisioning the databases
Installing Node.js on Ubuntu
Setting up Notes and User Authentication on the server
Setting up PM2 to manage Node.js processes
Twitter support for the hosted Notes app
Node.js microservice deployment with Docker
Installing Docker on your laptop
Starting Docker using Docker Toolbox and Docker Machine
Starting Docker with Docker for Windows/Mac
...

Table of contents

  1. Node.js Web Development Third Edition

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access Node.js Web Development - Third Edition by David Herron in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in JavaScript. We have over one million books available in our catalogue for you to explore.