Advanced Express Web Application Development

Advanced Express Web Application Development
eBook: $23.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $63.98    Print cover: $39.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • Learn how to build scalable, robust, and reliable web applications with Express using a test-first, feature-driven approach
  • Full of practical tips and real world examples, and delivered in an easy-to-read format
  • Explore and tackle the issues you encounter in commercially developing and deploying an Express application

Book Details

Language : English
Paperback : 148 pages [ 235mm x 191mm ]
Release Date : November 2013
ISBN : 1783282495
ISBN 13 : 9781783282494
Author(s) : Andrew Keig
Topics and Technologies : All Books, Web Development, Open Source

Table of Contents

Chapter 1: Foundations
Chapter 2: Building a Web API
Chapter 3: Templating
Chapter 4: Real-time Communication
Chapter 5: Security
Chapter 6: Scaling
Chapter 7: Production
  • Chapter 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
    • Chapter 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
      • Chapter 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
          • Chapter 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
            • Chapter 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
              • Chapter 7: Production
                • Error handling, domains, and crash-only design
                • Redis sessions
                • SSL termination
                • Caching
                • Favicon
                  • Minification
                • Compression
                • Logging
                • Summary

                Andrew Keig

                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 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, a property search startup.

                Code Downloads

                Download the code and support files for this book.

                Submit Errata

                Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


                - 8 submitted: last submission 12 Jun 2014

                Errata Type- Code | Page No: 8

                The code:

                "name": "chapter-1",
                "version": "0.0.0",
                "private": true,
                "scripts": {
                "start": "node app.js"
                "dependencies": {
                "express": "3.x"


                should be:


                "name": "chapter-1",
                "version": "0.0.0",
                "private": true,
                "scripts": {
                "start": "node app.js"
                ,"dependencies": {
                "express": "3.x"

                Errata Type- Code | Page No: 9

                The first command:

                npm install -g mocha –-save-dev


                should be:

                npm install mocha –-save-dev

                Errata Type- Code | Page No: 42

                The command in "Route improvements":

                npm install require-directory –save


                should be:


                npm install require-directory --save

                Errata Type- Typo | Page No: 35

                The following code:

                var item = _.pick(model, ['id','name','description''description'])


                Should be:


                var item = _.pick(model, ['id','name','description']);

                Errata Type- Technical | Page No: 21

                The last line:

                MongoDB to our configuration files ./lib/config/*.js:


                should be


                MongoDB to our configuration files ./config:


                Errata Type: Code | Page No: 41

                "exports.issues = function (req, res) {
      'Request' + req.url);" 

                should be

                "Project.prototype.issues = function(id, callback){ "

                Errata Type: Code | Page No: 25

                The following code block on page 25:

                var ProjectSchema =
                function Project() {};
       = function(name, data, callback){
                  var query = {'name': name};
                  var project = new ProjectSchema(data);
                  ProjectSchema.findOne(query, function(error, proj) {
                    if (error) return callback(error, null);
                    if (proj != null) return callback(null, null);
           (error, p) {
                      if (error) return callback(error, null);
                      return callback(null, p);

                }); });


                Should have the following line at the end:

                module.exports = Project;

                Errata Type: Code | Page No: 80

                instead of:
                bower install socketio-client
                should be:
                bower install --save

                Sample chapters

                You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

                Frequently bought together

                Advanced Express Web Application Development +    Oracle ADF Faces Cookbook =
                50% Off
                the second eBook
                Price for both: $37.50

                Buy both these recommended eBooks together and get 50% off the cheapest eBook.

                What you will learn from this book

                • Drive Express development via test
                • Build and consume a RESTful web API using client and server-side templating
                • Secure and protect Express with passport authentication and SSL via stud
                • Scale Express beyond a single server with Redis and Hipache
                • Decouple Express for improved scalability and maintainability
                • Support real-time application development with Socket.IO
                • Handle failures with a minimum impact to service availability using cluster and domains
                • Understand and cope with Express limitations, including when and where to go for help

                In Detail

                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.

                You will start by laying the foundations of your software development journey, as you drive-out features under test. You will move on quickly to expand on your existing knowledge, learning how to create a web API and a consuming client. You will then introduce a real-time element in your application.

                Following on from this, you will begin a process of incrementally improving your application as you tackle security, introduce SSL support, and how to handle security vulnerabilities. Next, the book will take you through the process of scaling and then decoupling your application. Finally, you will take a look at various ways you can improve your application's performance and reliability.


                A practical book, guiding the reader through the development of a single page application using a feature-driven approach.

                Who this book is for

                If you are an experienced JavaScript developer who wants to build highly scalable, real-world applications using Express, this book is ideal for you. This book is an advanced title and assumes that the reader has some experience with Node.js, JavaScript MVC web development frameworks, and has heard of Express before, or is familiar with it. You should also have a basic understanding of Redis and MongoDB.

                Code Download and Errata
                Packt Anytime, Anywhere
                Register Books
                Print Upgrades
                eBook Downloads
                Video Support
                Contact Us
                Awards Voting Nominations Previous Winners
                Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
                Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software