售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
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
Kicking the tires of Docker
Creating the AuthNet for the User Authentication service
MySQL for the Authentication service
Dockerizing the Authentication service
Putting Authnet together
Creating FrontNet for the Notes application
MySQL for the Notes application
Dockerizing the Notes application
Putting FrontNet together
Configuring remote access on Docker for Windows or Mac
Configuring remote access in VirtualBox on Docker toolbox
Exploring the Docker Toolbox VirtualBoxMachine
Controlling the location of MySQL data volumes
Deploying to the cloud with Docker compose
Docker compose files
Running the Notes application with Docker Compose
Deploying to cloud hosting with Docker Compose
Summary
11. Unit Testing
Testing asynchronous code
Assert – the simplest testing methodology
Testing a model
Mocha and Chai the chosen test tools
Notes model test suite
Configuring and running tests
More tests for the Notes model
Testing database models
Using Docker to manage test database servers
Docker Compose to orchestrate test infrastructure
Package.json scripts for Dockerized test infrastructure
Executing tests under Docker Compose
Testing REST backend services
Frontend headless browser testing with CasperJS
Setup
Improving testability in Notes UI
CasperJS test script for Notes
Running the UI test with CasperJS
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜