(This page has no text content)
1. Preface a. Who This Book Is For b. Notes on the Second Edition c. How This Book Is Organized d. Example Website e. Conventions Used in This Book f. Using Code Examples g. O’Reilly Online Learning h. How to Contact Us i. Acknowledgments 2. 1. Introducing Express a. The JavaScript Revolution b. Introducing Express c. Server-Side and Client-Side Applications d. A Brief History of Express e. Node: A New Kind of Web Server f. The Node Ecosystem g. Licensing h. Conclusion 3. 2. Getting Started with Node a. Getting Node
b. Using the Terminal c. Editors d. npm e. A Simple Web Server with Node i. Hello World ii. Event-Driven Programming iii. Routing iv. Serving Static Resources f. Onward to Express 4. 3. Saving Time with Express a. Scaffolding b. The Meadowlark Travel Website c. Initial Steps i. Views and Layouts ii. Static Files and Views iii. Dynamic Content in Views iv. Conclusion 5. 4. Tidying Up a. File and Directory Structure b. Best Practices c. Version Control d. How to Use Git with This Book
i. If You’re Following Along by Doing It Yourself ii. If You’re Following Along by Using the Official Repository e. npm Packages f. Project Metadata g. Node Modules h. Conclusion 6. 5. Quality Assurance a. The QA Plan b. QA: Is It Worth It? c. Logic Versus Presentation d. The Types of Tests e. Overview of QA Techniques f. Installing and Configuring Jest g. Unit Testing i. Mocking ii. Refactoring the Application for Testability iii. Writing Our First Test iv. Test Maintenance v. Code Coverage h. Integration Testing i. Linting
j. Continuous Integration k. Conclusion 7. 6. The Request and Response Objects a. The Parts of a URL b. HTTP Request Methods c. Request Headers d. Response Headers e. Internet Media Types f. Request Body g. The Request Object h. The Response Object i. Getting More Information j. Boiling It Down i. Rendering Content ii. Processing Forms iii. Providing an API k. Conclusion 8. 7. Templating with Handlebars a. There Are No Absolute Rules Except This One b. Choosing a Template Engine c. Pug: A Different Approach d. Handlebars Basics
i. Comments ii. Blocks iii. Server-Side Templates iv. Views and Layouts v. Using Layouts (or Not) in Express vi. Sections vii. Partials viii. Perfecting Your Templates e. Conclusion 9. 8. Form Handling a. Sending Client Data to the Server b. HTML Forms c. Encoding d. Different Approaches to Form Handling e. Form Handling with Express f. Using Fetch to Send Form Data g. File Uploads i. File Uploads with Fetch h. Improving File Upload UI i. Conclusion 10. 9. Cookies and Sessions a. Externalizing Credentials
b. Cookies in Express c. Examining Cookies d. Sessions i. Memory Stores ii. Using Sessions e. Using Sessions to Implement Flash Messages f. What to Use Sessions For g. Conclusion 11. 10. Middleware a. Middleware Principles b. Middleware Examples c. Common Middleware d. Third-Party Middleware e. Conclusion 12. 11. Sending Email a. SMTP, MSAs, and MTAs b. Receiving Email c. Email Headers d. Email Formats e. HTML Email f. Nodemailer i. Sending Mail
ii. Sending Mail to Multiple Recipients g. Better Options for Bulk Email h. Sending HTML Email i. Images in HTML Email ii. Using Views to Send HTML Email iii. Encapsulating Email Functionality i. Conclusion 13. 12. Production Concerns a. Execution Environments b. Environment-Specific Configuration c. Running Your Node Process d. Scaling Your Website i. Scaling Out with App Clusters ii. Handling Uncaught Exceptions iii. Scaling Out with Multiple Servers e. Monitoring Your Website i. Third-Party Uptime Monitors f. Stress Testing g. Conclusion 14. 13. Persistence a. Filesystem Persistence b. Cloud Persistence
c. Database Persistence i. A Note on Performance ii. Abstracting the Database Layer iii. Setting Up MongoDB iv. Mongoose v. Database Connections with Mongoose vi. Creating Schemas and Models vii. Seeding Initial Data viii. Retrieving Data ix. Adding Data x. PostgreSQL xi. Adding Data d. Using a Database for Session Storage e. Conclusion 15. 14. Routing a. Routes and SEO b. Subdomains c. Route Handlers Are Middleware d. Route Paths and Regular Expressions e. Route Parameters f. Organizing Routes g. Declaring Routes in a Module
h. Grouping Handlers Logically i. Automatically Rendering Views j. Conclusion 16. 15. REST APIs and JSON a. JSON and XML b. Our API c. API Error Reporting d. Cross-Origin Resource Sharing e. Our Tests f. Using Express to Provide an API g. Conclusion 17. 16. Single-Page Applications a. A Short History of Web Application Development b. SPA Technologies c. Creating a React App d. React Basics i. The Home Page ii. Routing iii. Vacations Page—Visual Design iv. Vacations Page—Server Integration v. Sending Information to the Server vi. State Management
vii. Deployment Options e. Conclusion 18. 17. Static Content a. Performance Considerations b. Content Delivery Networks c. Designing for CDNs i. Server-Rendered Website ii. Single-Page Applications d. Caching Static Assets e. Changing Your Static Content f. Conclusion 19. 18. Security a. HTTPS i. Generating Your Own Certificate ii. Using a Free Certificate Authority iii. Purchasing a Certificate iv. Enabling HTTPS for Your Express App v. A Note on Ports vi. HTTPS and Proxies b. Cross-Site Request Forgery c. Authentication i. Authentication Versus Authorization
ii. The Problem with Passwords iii. Third-Party Authentication iv. Storing Users in Your Database v. Authentication Versus Registration and the User Experience vi. Passport vii. Role-Based Authorization viii. Adding Authentication Providers d. Conclusion 20. 19. Integrating with Third-Party APIs a. Social Media i. Social Media Plugins and Site Performance ii. Searching for Tweets iii. Rendering Tweets b. Geocoding i. Geocoding with Google ii. Geocoding Your Data iii. Displaying a Map c. Weather Data d. Conclusion 21. 20. Debugging a. The First Principle of Debugging
b. Take Advantage of REPL and the Console c. Using Node’s Built-in Debugger d. Node Inspector Clients e. Debugging Asynchronous Functions f. Debugging Express g. Conclusion 22. 21. Going Live a. Domain Registration and Hosting i. Domain Name System ii. Security iii. Top-Level Domains iv. Subdomains v. Nameservers vi. Hosting vii. Deployment b. Conclusion 23. 22. Maintenance a. The Principles of Maintenance i. Have a Longevity Plan ii. Use Source Control iii. Use an Issue Tracker iv. Exercise Good Hygiene
v. Don’t Procrastinate vi. Do Routine QA Checks vii. Monitor Analytics viii. Optimize Performance ix. Prioritize Lead Tracking x. Prevent “Invisible” Failures b. Code Reuse and Refactoring i. Private npm Registry ii. Middleware c. Conclusion 24. 23. Additional Resources a. Online Documentation b. Periodicals c. Stack Overflow d. Contributing to Express e. Conclusion 25. Index
Web Development with Node and Express Leveraging the JavaScript Stack SECOND EDITION Ethan Brown
Web Development with Node and Express by Ethan Brown Copyright © 2020 Ethan Brown. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: 800-998-9938 or corporate@oreilly.com. Acquisitions Editor: Jennifer Pollock Developmental Editor: Angela Rufino Production Editor: Nan Barber Copyeditor: Kim Wimpsett Proofreader: Sharon Wilkey Indexer: WordCo Indexing Services, Inc. Interior Designer: David Futato
Cover Designer: Karen Montgomery Illustrator: Rebecca Demarest November 2019: Second Edition Revision History for the Second Edition 2019-11-12: First Release See http://oreilly.com/catalog/errata.csp?isbn=9781492053514 for release details. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Web Development with Node and Express, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc. The views expressed in this work are those of the author, and do not represent the publisher’s views. While the publisher and the author have used good faith efforts to ensure that the information and instructions contained in this work are accurate, the publisher and the author disclaim all responsibility for errors or omissions, including without limitation responsibility for damages resulting from the use of or reliance on this work. Use of the information and instructions contained in this work is at your own risk. If any code samples or other technology this work contains or describes is subject to open source licenses or the intellectual property rights of others, it is your responsibility to ensure that your use thereof complies with such licenses and/or rights. 978-1-492-05351-4
Dedication This book is dedicated to my family: My father, Tom, who gave me a love of engineering; my mother, Ann, who gave me a love of writing; and my sister, Meris, who has been a constant companion.
Comments 0
Loading comments...
Reply to Comment
Edit Comment