售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Node Web Development Second Edition
Table of Contents
Node Web Development Second Edition
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
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
The capabilities of Node
Server-side JavaScript
Why should you use Node?
Threaded versus asynchronous event-driven architecture
Performance and utilization
Is Node a cancerous scalability disaster?
Server utilization, the bottom line, and green web hosting
What's in a name – Node, Node.js, or Node.JS?
Summary
2. Setting up Node
System requirements
Installing Node using package managers
Installing on Mac OS X with MacPorts
Installing on Mac OS X with Homebrew
Installing on Linux from package management systems
Installing the Node distribution from nodejs.org
Installing Node on Windows using Chocolatey Gallery
Installing the StrongLoop Node distribution
Installing from source on POSIX-like systems
Installing prerequisites
Installing developer tools on Mac OS X
Installing from source for all POSIX-like systems
Maintaining multiple Node installs simultaneously
Run a few commands; testing the commands
Node's command-line tools
Running a simple script with Node
Launching a server with Node
npm – the Node package manager
Starting Node servers at system startup
Summary
3. Node Modules
Defining a module
Node modules
Node's algorithm for resolving require(module)
Module identifiers and path names
Local modules within your application
Bundling external dependencies with your application
System-wide modules in NODE_PATH and elsewhere
Complex modules – modules as directories
Node package manager
The npm package format
Finding npm packages
Using the npm commands
Getting help with npm
Viewing package information
Installing an npm package
Installing native code modules on Windows
Installing packages local to a module
Eliminating duplicate modules installed beneath node_modules
Listing the currently installed packages
Package scripts
Editing and exploring installed package content
Updating outdated packages you've installed
Uninstalling an installed npm package
Developing and publishing npm packages
npm configuration settings
Package version strings and ranges
CommonJS modules
Demonstrating module encapsulation
Summary
4. HTTP Servers and Clients – A Web Application's First Steps
Sending and receiving events with EventEmitters
EventEmitter theory
HTTP server applications
HTTP Sniffer – listening to the HTTP conversation
Web application frameworks
Getting started with Express
Walking through the default Express application
Calculating the Fibonacci sequence with Express
Computationally intensive code and the 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 Node modules
Summary
5. Implementing a Simple Express Application
Express and the MVC paradigm
Creating the Notes application code
The Notes model
The Notes home page
Adding a new note (create)
Viewing notes (read)
Editing an existing note (update)
Deleting notes (destroy)
Changing the look of an Express application
Scaling up and running multiple instances
Summary
6. Data Storage and Retrieval
Asynchronizing the Notes application
Injecting the model configuration into routers
The notes router
Storing notes in files
Configuring app.js
Storing notes with the LevelUP data store
Installing LevelUP
LevelUP model code for Notes
Configuring app.js for LevelUP
Storing notes in SQL – SQLite3
Setting up a schema with SQLite3
Model code
Configuring app.js
Storing notes the ORM way with the Sequelize module
Schema setup and model code
Configuring app.js
Storing notes in MongoDB with Mongoose
Implementing the Notes model in Mongoose
Configuring app.js
Summary
7. Multiuser Authorization, Deployment, Scaling, and Hosting
User authentication
Changes in app.js
The Sequelize-based users model
Routing module for the login, logout, and account pages
Initializing the user table
Running the Notes application
Deploying Notes on Debian
Scaling to use all cores on multi-core servers
Deploying Notes on cloud hosting (AppFog)
Summary
8. Dynamic Interaction between the Client and Server Application
Adding real-time web features to Notes
Introducing Socket.IO
Initializing Socket.IO with Express
Setting up the client code
Events between the Notes server and client code
Modifying the Notes model to send events
Sending the events from the Notes server
Browser-side event handlers
Running the Notes application with Socket.IO
Listening to the heartbeat and cleaning up when it stops
Sending messages between users
Socket.IO events for sending messages between users
Data model to store messages
Setting up client-side code for sending messages
Dispatching messages between the client- and server-side
Displaying messages to the user
Running Notes and sending messages
Summary
9. Unit Testing
Testing asynchronous code
Assert – the simplest testing methodology
Testing a model
Executing the tests
Testing router functions
Diagnosing a failing test case
Making it easy to run the tests
Summary
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜