Advanced Express Web Application Development
By Andrew Keig
()
About this ebook
Related to Advanced Express Web Application Development
Related ebooks
jQuery Mobile Web Development Essentials - Third Edition Rating: 0 out of 5 stars0 ratingsAngularJS Deployment Essentials Rating: 0 out of 5 stars0 ratingsLearning Behavior-driven Development with JavaScript Rating: 5 out of 5 stars5/5Opa Application Development Rating: 0 out of 5 stars0 ratingsGetting Started with hapi.js Rating: 5 out of 5 stars5/5Jasmine JavaScript Testing - Second Edition Rating: 0 out of 5 stars0 ratingsCloud Development and Deployment with CloudBees Rating: 0 out of 5 stars0 ratingsAngular 2 Components Rating: 0 out of 5 stars0 ratingsApache Solr PHP Integration Rating: 0 out of 5 stars0 ratingsBeginning PHP: Master the latest features of PHP 7 and fully embrace modern PHP development Rating: 0 out of 5 stars0 ratingsNW.js Essentials Rating: 0 out of 5 stars0 ratingsInstant Highcharts Rating: 0 out of 5 stars0 ratingsCrafting HTML Email Rating: 0 out of 5 stars0 ratingsGetting Started with Grunt: The JavaScript Task Runner Rating: 3 out of 5 stars3/5Instant Node Package Manager Rating: 2 out of 5 stars2/5Jump Start Web Performance Rating: 0 out of 5 stars0 ratingsResponsive Design High Performance Rating: 0 out of 5 stars0 ratingsVue.js: Tools & Skills Rating: 0 out of 5 stars0 ratingsReal-World Next.js: Build scalable, high-performance, and modern web applications using Next.js, the React framework for production Rating: 0 out of 5 stars0 ratingsMySQL 5.1 Plugin Development Rating: 0 out of 5 stars0 ratingsApache Cordova in Action Rating: 0 out of 5 stars0 ratingsLearning Magento Theme Development Rating: 0 out of 5 stars0 ratingsPHP Team Development Rating: 3 out of 5 stars3/5Mastering Magento Theme Design Rating: 0 out of 5 stars0 ratings
Programming For You
Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5C Programming For Beginners: The Simple Guide to Learning C Programming Language Fast! Rating: 5 out of 5 stars5/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 5 out of 5 stars5/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Excel 101: A Beginner's & Intermediate's Guide for Mastering the Quintessence of Microsoft Excel (2010-2019 & 365) in no time! Rating: 0 out of 5 stars0 ratingsCoding with JavaScript For Dummies Rating: 0 out of 5 stars0 ratingsLinux: Learn in 24 Hours Rating: 5 out of 5 stars5/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5Beginning Programming with C++ For Dummies Rating: 4 out of 5 stars4/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5Python Data Structures and Algorithms Rating: 5 out of 5 stars5/5Narrative Design for Indies: Getting Started Rating: 4 out of 5 stars4/5C All-in-One Desk Reference For Dummies Rating: 5 out of 5 stars5/5Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5C# 7.0 All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsJavaScript All-in-One For Dummies Rating: 5 out of 5 stars5/5Python: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5
Reviews for Advanced Express Web Application Development
0 ratings0 reviews
Book preview
Advanced Express Web Application Development - Andrew Keig
Table of Contents
Advanced Express Web Application Development
Credits
About the Author
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. Foundations
Feature set
Installation
package.json
Testing Express with Mocha and SuperTest
Feature: Heartbeat
Continuous testing with Mocha
Code coverage with Mocha and JSCoverage
Configuring Express with Nconf
Extracting routes
404 handling middleware
Logging middleware
Logging with Winston
Task automation with Grunt
Summary
2. Building a Web API
Persisting data with MongoDB and Mongoose
GitHub tokens
Feature: Create a project
Feature: Get a project
Feature: Edit a project
Feature: Delete a project
Feature: List projects
GitHub API
Feature: List repositories
Feature: List commits
Feature: List issues
Validating parameters with param middleware
Route improvements
Summary
3. Templating
Server-side templating
Feature: Master Page
Package management with Bower
Templates
Client-side development with Backbone.js
Feature: List projects
Feature: List repositories
Feature: Create a project
Feature: Edit a project
Feature: Delete a project
Feature: List commits
Feature: List issues
Summary
4. Real-time Communication
Caching data with Redis
Populating Redis
Socket.IO
Socket.IO on the client
Scheduling Redis population
Summary
5. Security
Setting up Passport
Acceptance testing with Cucumber and Zombie.js
Feature: Authentication
Scenario: User logs in successfully
Scenario: User logs out successfully
Securing our site with HTTPS
Sharing Express sessions with Socket.IO
Cross-site request forgery
Improving security with HTTP headers and helmet
Summary
6. Scaling
Scaling Express sessions with Redis
Scaling Socket.IO with Redis
Scaling Express horizontally
vision-core
vision-api
vision-worker
vision-web
Vertical scale with Cluster
Balancing load with Hipache
Summary
7. Production
Error handling, domains, and crash-only design
Redis sessions
SSL termination
Caching
Favicon
Minification
Compression
Logging
Summary
Index
Advanced Express Web Application Development
Advanced Express Web Application Development
Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: November 2013
Production Reference: 1181113
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78328-249-4
www.packtpub.com
Cover Image by Rima Pawooskar (<riima@hotmail.com>)
Credits
Author
Andrew Keig
Reviewers
Dave Poon
Artem Vovsya
Acquisition Editors
Erol Staveley
Owen Roberts
Commissioning Editors
Subho Gupta
Sharvari Tawde
Technical Editors
Kapil Hemnani
Tarunveer Shetty
Copy Editors
Sarang Chari
Brandt D'Mello
Lavina Pereira
Project Coordinator
Sherin Padayatty
Proofreader
Simran Bhogal
Indexer
Tejal Daruwale
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
About the Author
Andrew Keig is a London based web developer who has been building web applications since 2000. He is the author of Packt's Instant RabbitMQ Messaging Application Development How-to. Andrew has a degree in Computing and blogs at blog.airasoul.net on topics he is passionate about, such as Node.js, REST, Web APIs, and behaviour-driven development. He also contributes to various Node.js open source projects. He is a director at Airasoul, which specializes in the design and build of scalable, RESTful, specification-driven, and real-time web-based applications on the Node.js stack. He is also the co-founder of openue.com, a property search startup.
This book is the culmination of my experience working on multiple Node.js projects. I thank those who worked with me: Johnny Hall, Mehdi Avdi, Jozz Hart, Keith Bowditch, Lee Wilson, and Craig Strong.
I would like to thank TJ. Holowaychuk, the author of Express, the author of Node.js, Ryan Dahl, Node's current custodian Isaac Z. Schlueter, and the thousands of Node module developers who have all contributed to making Node.js an awesome space to work in.
Finally, I would also like to thank my reviewers: Dave Poon, and Artem Vovsya for their invaluable input and the team at Packt Publishing for their support.
Finally, thank you to all my family.
About the Reviewers
Dave Poon is a web developer and designer based in Sydney. He started his career as a freelance graphic and web designer in 1998 and worked with web development agencies and medium-size enterprises. After graduating from Central Queensland University with a degree in Multimedia Studies and Master's degree in IT, he began his love affair with Drupal, and worked for a variety of companies that use Drupal.
Currently, he is a Design Lead at Suncorp, one of the biggest financial institutions in Australia. He is also the co-founder of Erlango (http://erlango.com), a digital product design startup, located in Sydney and Hong Kong, that creates user-centered digital products and tools for designers and users.
He is also the author of Packt's Drupal 7 Fields/CCK.
I would like to thank my wife Rita for her endless patience and support. Without her, what I do would be meaningless.
And also I would like to thank my father for his continued encouragement.
Artem Vovsya has been writing software since 2006, when he started working as a Delphi developer for a little software company. He got his Bachelor's degree in Computer Engineering. He tried his hand at being a Delphi and .NET developer. Two years ago, he fell in love with Node.js, and now he's writing frontend and backend code completely in JavaScript.
Currently he is a frontend developer at Yandex, the leading Russian search engine.
www.PacktPub.com
Support files, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
Why Subscribe?
Fully searchable across every book published by Packt
Copy and paste, print and bookmark content
On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
This book is dedicated to my wife Rima and beloved son Indie.
Thank you both for your love and understanding.
Preface
Building an Express application that is reliable, robust, maintainable, testable, and can scale beyond a single server requires a bit of extra thought and effort. Express applications that need to survive in a production environment will need to reach out to the Node ecosystem and beyond for support. Advanced Express Web Application Development aims to deliver a working real-world, single-page application that can meet these goals and allow us the opportunity to explore the more advanced features of Express.
What this book covers
Chapter 1, Foundations, lays the foundation as we put in place a skeleton application; we introduce testing and automation practices that we will use to build our example single-page application.
Chapter 2, Building a Web API, helps in building a web API that our application will consume.
Chapter 3, Templating, helps you create a consuming client with a working web API in place and explore the client- and server-side templating.
Chapter 4, Real-time Communication, helps us to add real-time updates to content displayed in our single-page application.
Chapter 5, Security, guides us to secure our application as we look at authentication, security vulnerabilities, and SSL.
Chapter 6, Scaling, demonstrates scaling our Express application using Redis, and also looks at the benefits of decoupling an Express application.
Chapter 7, Production, examines real-world Express deployment issues such as performance, robustness, and reliability.
What you need for this book
In