Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Web Development with Node and Express
Dedication
Foreword
Preface
Who This Book Is For
How This Book Is Organized
Example Website
Conventions Used in This Book
Using Code Examples
Safari® Books Online
How to Contact Us
Acknowledgments
1. Introducing Express
The JavaScript Revolution
Introducing Express
A Brief History of Express
Upgrading to Express 4.0
Node: A New Kind of Web Server
The Node Ecosystem
Licensing
2. Getting Started with Node
Getting Node
Using the Terminal
Editors
npm
A Simple Web Server with Node
Hello World
Event-Driven Programming
Routing
Serving Static Resources
Onward to Express
3. Saving Time with Express
Scaffolding
The Meadowlark Travel Website
Initial Steps
Views and Layouts
Static Files and Views
Dynamic Content in Views
Conclusion
4. Tidying Up
Best Practices
Version Control
How to Use Git with This Book
If You’re Following Along by Doing It Yourself
If You’re Following Along by Using the Official Repository
npm Packages
Project Metadata
Node Modules
5. Quality Assurance
QA: Is It Worth It?
Logic Versus Presentation
The Types of Tests
Overview of QA Techniques
Running Your Server
Page Testing
Cross-Page Testing
Logic Testing
Linting
Link Checking
Automating with Grunt
Continuous Integration (CI)
6. The Request and Response Objects
The Parts of a URL
HTTP Request Methods
Request Headers
Response Headers
Internet Media Types
Request Body
Parameters
The Request Object
The Response Object
Getting More Information
Boiling It Down
Rendering Content
Processing Forms
Providing an API
7. Templating with Handlebars
There Are No Absolute Rules Except This One
Choosing a Template Engine
Jade: A Different Approach
Handlebars Basics
Comments
Blocks
Server-Side Templates
Views and Layouts
Using Layouts (or Not) in Express
Partials
Sections
Perfecting Your Templates
Client-Side Handlebars
Conclusion
8. Form Handling
Sending Client Data to the Server
HTML Forms
Encoding
Different Approaches to Form Handling
Form Handling with Express
Handling AJAX Forms
File Uploads
jQuery File Upload
9. Cookies and Sessions
Externalizing Credentials
Cookies in Express
Examining Cookies
Sessions
Memory Stores
Using Sessions
Using Sessions to Implement Flash Messages
What to Use Sessions For
10. Middleware
Common Middleware
Third-Party Middleware
11. Sending Email
SMTP, MSAs, and MTAs
Receiving Email
Email Headers
Email Formats
HTML Email
Nodemailer
Sending Mail
Sending Mail to Multiple Recipients
Better Options for Bulk Email
Sending HTML Email
Images in HTML Email
Using Views to Send HTML Email
Encapsulating Email Functionality
Email as a Site Monitoring Tool
12. Production Concerns
Execution Environments
Environment-Specific Configuration
Scaling Your Website
Scaling Out with App Clusters
Handling Uncaught Exceptions
Scaling Out with Multiple Servers
Monitoring Your Website
Third-Party Uptime Monitors
Application Failures
Stress Testing
13. Persistence
Filesystem Persistence
Cloud Persistence
Database Persistence
A Note on Performance
Setting Up MongoDB
Mongoose
Database Connections with Mongoose
Creating Schemas and Models
Seeding Initial Data
Retrieving Data
Adding Data
Using MongoDB for Session Storage
14. Routing
Routes and SEO
Subdomains
Route Handlers Are Middleware
Route Paths and Regular Expressions
Route Parameters
Organizing Routes
Declaring Routes in a Module
Grouping Handlers Logically
Automatically Rendering Views
Other Approaches to Route Organization
15. REST APIs and JSON
JSON and XML
Our API
API Error Reporting
Cross-Origin Resource Sharing (CORS)
Our Data Store
Our Tests
Using Express to Provide an API
Using a REST Plugin
Using a Subdomain
16. Static Content
Performance Considerations
Future-Proofing Your Website
Static Mapping
Static Resources in Views
Static Resources in CSS
Static Resources in Server-Side JavaScript
Static Resources in Client-Side JavaScript
Serving Static Resources
Changing Your Static Content
Bundling and Minification
Skipping Bundling and Minification in Development Mode
A Note on Third-Party Libraries
QA
Summary
17. Implementing MVC in Express
Models
View Models
Controllers
Conclusion
18. Security
HTTPS
Generating Your Own Certificate
Using a Free Certificate Authority
Purchasing a Certificate
Enabling HTTPS for Your Express App
A Note on Ports
HTTPS and Proxies
Cross-Site Request Forgery
Authentication
Authentication Versus Authorization
The Problem with Passwords
Third-Party Authentication
Storing Users in Your Database
Authentication Versus Registration and the User Experience
Passport
Setting up Passport
Role-Based Authorization
Adding Additional Authentication Providers
Conclusion
19. Integrating with Third-Party APIs
Social Media
Social Media Plugins and Site Performance
Searching for Tweets
Rendering Tweets
Geocoding
Geocoding with Google
Usage restrictions
Geocoding Your Data
Displaying a Map
Improving Client-Side Performance
Weather Data
Conclusion
20. Debugging
The First Principle of Debugging
Take Advantage of REPL and the Console
Using Node’s Built-in Debugger
Node Inspector
Debugging Asynchronous Functions
Debugging Express
21. Going Live
Domain Registration and Hosting
Domain Name System
Security
Top-Level Domains
Subdomains
Nameservers
Hosting
Traditional hosting, or cloud hosting?
XaaS
The behemoths
Boutique hosting
Deployment
Git deployment
Deployment to Azure
Manual Git-based deployment
Amazon deployment with Elastic Beanstalk
Conclusion
22. Maintenance
The Principles of Maintenance
Have a Longevity Plan
Use Source Control
Use an Issue Tracker
Exercise Good Hygiene
Don’t Procrastinate
Do Routine QA Checks
Monitor Analytics
Optimize Performance
Prioritize Lead Tracking
Prevent “Invisible” Failures
Code Reuse and Refactoring
Private npm Registry
Middleware
Module exposes middleware function directly
Module exposes a function that returns middleware
Module exposes an object that contains middleware
Module exposes an object constructor
Conclusion
23. Additional Resources
Online Documentation
Periodicals
Stack Overflow
Contributing to Express
Conclusion
Index
Colophon
Copyright
← Prev
Back
Next →
← Prev
Back
Next →