O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Express Web Application Development

Book Description

Here’s a comprehensive guide to making the most of Express’s flexibility in building web applications. With lots of screenshots and examples, it’s the perfect step-by-step manual for those with an intermediate knowledge of JavaScript.

  • Exploring all aspects of web development using the Express framework
  • Starts with the essentials
  • Expert tips and advice covering all Express topics

In Detail

Express is a minimal and flexible node.js web application framework, providing a robust set of features for building single and multi-page, and hybrid web applications. It provides a thin layer of features fundamental to any web application, without obscuring features that developers know and love in node.js.

"Express Web Application Development" is a comprehensive guide for those looking to learn how to use the Express web framework for web application development.

Starting with the initial setup of the Express web framework, "Express Web Application Development" helps you to understand the fundamentals of the framework. By the end of "Express Web Application Development", you will have acquired enough knowledge and skills to create production-ready Express apps. All of this is made possible by the incremental introduction of more advanced topics, starting from the very essentials.

On the way to mastering Express for application development, we teach you the more advanced topics such as routes, views, middleware, forms, sessions, cookies and various other aspects of configuring an Express application. Jade; the recommended HTML template engine, and Stylus; the CSS pre-processor for Express, are covered in detail.

Last, but definitely not least, Express Web Application Development also covers practices and setups that are required to make Express apps production-ready.

Table of Contents

  1. Express Web Application Development
    1. Table of Contents
    2. Express Web Application Development
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Downloading the example code
      7. Customer support
        1. Errata
        2. Piracy
        3. Questions
    8. 1. What is Express?
      1. What is Express?
        1. The story of Express
      2. Installing Express
      3. The stuff that makes up Express
        1. The application object
        2. The request object
        3. The response object
      4. Concepts used in Express
        1. Asynchronous JavaScript
        2. Node modules
        3. Express apps are Node modules
        4. Middlewares
        5. Request flow
        6. Node HTTP/HTTPS API
      5. Summary
    9. 2. Your First Express App
      1. Your first Express app
        1. The Express manifest file
        2. A very basic Express app
          1. Starting and stopping the app
          2. Analyzing the output
        3. Express app with views
        4. A public directory for the app
      2. Auto-generating an Express app
      3. Empowering Express with middlewares
      4. Empowering Express with Node modules
      5. Logging requests to the App
      6. Using a configuration file
      7. Setting and getting application options
      8. Express in different environments
      9. Summary
    10. 3. Understanding Express Routes
      1. What are Routes?
        1. A quick introduction to HTTP verbs
      2. Revisiting the router middleware
      3. Defining routes for the app
        1. Route identifiers
        2. Order of route precedence
      4. How to handle routes
      5. How to organize routes
        1. Using Node modules
        2. Namespaced routing
        3. Resourceful routing
        4. Making a choice
      6. Summary
    11. 4. Response From the Server
      1. A primer on HTTP response
        1. HTTP status codes
          1. 1xx
          2. 2xx
          3. 3xx
          4. 4xx
          5. 5xx
        2. HTTP response headers
        3. Media types
      2. HTTP response in Express
        1. Setting the HTTP status code
        2. Setting HTTP headers
        3. Sending data
          1. Plain text
          2. HTML
          3. JSON
          4. JSONP
          5. Serving static files
          6. Serving files programmatically
          7. Serving error pages
          8. Content negotiation
          9. Redirecting a request
      3. Summary
    12. 5. The Jade Templating Language
      1. What is Jade?
      2. Generating HTML tags
        1. Hierarchy of HTML elements
        2. Assigning IDs
        3. Assigning classes
        4. Specifying HTML attributes
      3. Creating text content
      4. Filters
      5. Declaring the document's Doctype
      6. Programmability in Jade
        1. Variables
        2. Interpolation
        3. Control structures
          1. JavaScript constructs
          2. Jade constructs
            1. if, else if, and else
            2. for
            3. each
            4. while
            5. unless
            6. case
      7. Modularization
        1. Includes
        2. Template inheritance
        3. Mixins
      8. Escaping
      10. Summary
    13. 6. The Stylus CSS Preprocessor
      1. Introduction
      2. Enabling Stylus in Express
      3. Selectors
        1. Selector blocks
        2. Hierarchy
      4. Rules
        1. @import
        2. @media
        3. @font-face
        4. @keyframes
        5. @extend
        6. @css
      5. Programmability
        1. Variables
          1. Literals
          2. Lists
          3. Tuples
            1. Listed tuples
        2. Mixins
        3. Functions
        5. Operators
        6. Conditionals
          1. if, else if, and else
          2. unless
      6. Built-in functions
      7. Summary
    14. 7. Forms, Cookies, and Sessions
      1. Using forms to submit data
        1. Handling GET submissions
          1. Reading form data
          2. Reading URL query parameters
          3. Handling multiple options
        2. Handling POST submissions
          1. Enabling POST data parsing
          2. Reading form data
          3. Handling text-only forms
          4. Handling file uploads
          5. More about file uploads
        3. Submission via simulated methods
      2. Data in named segments
        1. Reading data
      3. Using cookies to store data
        1. Creating cookies
        2. Reading cookies
        3. Updating cookies
        4. Session cookies
        5. Signed cookies
        6. Deleting cookies
      4. Using sessions to store data
        1. Cookie-based sessions
        2. Session store-based sessions
          1. MemoryStore
          2. RedisStore
          3. MongoStore
        3. Session variables
          1. Setting session variables
          2. Reading session variables
          3. Updating session variables
          4. Deleting session variables
        4. Deleting a session
          1. Deleting a cookie-based session
          2. Deleting a session store-based session
      5. Summary
    15. 8. Express in Production
      1. What the is production environment?
        1. What changes in production mode?
        2. Simulating production environment
      2. Benchmarking the app
      3. Creating an app cluster
      4. Handling critical events
        1. Closing the server
        2. Handling uncaught errors
          1. Using try-catch to catch uncaught errors
          2. Using domains to handle uncaught errors
          3. What to do in case of uncaught errors – to terminate the process or not to terminate?
        3. Handling process termination
      5. Ensuring uptime
        1. Forever
        2. Upstart
      6. Using a reverse proxy
        1. The trust proxy option
      7. Summary
    16. Index