Express Web Application Development


Express Web Application Development
eBook: $29.99
Formats: PDF, PacktLib, ePub and Mobi formats
$25.49
save 15%!
Print + free eBook + free PacktLib access to the book: $79.98    Print cover: $49.99
$49.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Exploring all aspects of web development using the Express framework
  • Starts with the essentials
  • Expert tips and advice covering all Express topics

Book Details

Language : English
Paperback : 236 pages [ 235mm x 191mm ]
Release Date : June 2013
ISBN : 1849696543
ISBN 13 : 9781849696548
Author(s) : Hage Yaapa
Topics and Technologies : All Books, Web Development

Table of Contents

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

                  Hage Yaapa

                  Hage Yaapa is a contributing developer of Express and the head of Web and Node.js development at Sourcebits. He joined one of the best medical schools in India, JIPMER, to become a doctor, but dropped out to pursue his burning passion for computers and the Internet. He has been creating websites and apps since 1999 using a very wide array of web technologies. He is a self-taught programmer and everything he knows about technology, he learned on his own from the Internet and books. Yaapa blogs about Node.js, Express, and other web technologies on his website www.hacksparrow.com, as Captain Hack Sparrow.
                  Sorry, we don't have any reviews for this title yet.

                  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.


                  Errata

                  - 5 submitted: last submission 17 Oct 2013

                  Errata type: Code | Page number: 64

                  In the following case, http://localhost:3000/abcd will always print "abc*" , even though the next route also matches the pattern:

                  app.get('/abcd', function(req, res) { res.send('abcd'); });

                  app.get('/abc*', function(req, res) { res.send('abc*'); });

                  Reversing the order will make it print "abc*":

                  app.get('/abc*', function(req, res) { res.send('abc*'); });

                  app.get('/abcd', function(req, res) { res.send('abcd'); });

                  SHOULD BE:

                  In the following case, http://localhost:3000/abcd will always print "abc*" , even though the next route also matches the pattern:

                  app.get('/abc*', function(req, res) { res.send('abc*'); });

                  app.get('/abcd', function(req, res) { res.send('abcd'); });

                  Reversing the order will make it print "abcd":

                  app.get('/abcd', function(req, res) { res.send('abcd'); });

                  app.get('/abc*', function(req, res) { res.send('abc*'); });

                   

                  Errata type : Typo | Page number : 8 | Errata date : August 22, 2013

                  In the Install Express section, the command to install node dependencies is:

                  $sudo apt-get -y install build-essential g++ libssl-devpkg-config

                  However, there should be a whitespace between libssl-dev and pkg-config. The correct command would be:

                  $sudo apt-get -y install build-essential g++ libssl-dev pkg-config

                   

                  Errata type : Typo |  Page number : 94 | Errata date : September 2, 2013

                  The line in the code snippet: if (err) { condole.log(err) } , should be: if (err) { console.log(err) }

                  This typo is also present in the downloaded code sample.

                  Errata type : Typo | Page number : 76 | Errata date : September 2, 2013

                  Text reads: "You will learn more about forums and how to make other type of HTTP requests in Chapter 6, The Stylus CSS Prepocessor."

                  This should read as: "You will learn more about forums and how to make other types of HTTP requests in Chapter 7, Forums, Cookies, and Sessions."

                  Errata type: code | Page number: 112

                  Query 1: In Chapter 5
                  Replace script with script., and style with style.
                  What used to be
                  script var greeting = 'Welcome to Jade';
                  should now be
                  script. var greeting = 'Welcome to Jade';
                  What used to be style(type='text/css') #wrapper { padding: 0 }
                  should now be
                  style.(type='text/css'). #wrapper { padding: 0 }

                  Errata type: code | Page number: 123

                  Query 2:

                  In Chapter 5
                  The example of while loop shown in the book should have the following changes:
                  Enclose the condition within braces in the while construct and mark i++ with a hyphen.
                  What used to be
                  i= 0 while i < 5 div= i i++
                  should now be
                  i = 0 while (i < 5) div= i - i++

                  Errata type: code | Page number: 119

                  Query 3: In Chapter 5
                  p= '© ' + new Date().getFullYear()
                  should be p!= '© ' + new Date().getFullYear()

                  Errata type: Others | Page number: 123

                  Query 6 and 7: In Chapter 5
                  The example of while loop shown in the book should have the following changes:
                  Enclose the condition within braces in the while construct and mark i++ with a hyphen.
                  This used to be
                  i= 0 while i < 5 div= i i++
                  should now be
                  i = 0 while (i < 5) div= i - i++

                  Errata type: code | Page number: 123

                  Query 4: In Chapter 5
                  What used to be :
                  case hero.role when 'captain' div Yarr! when 'hacker' div w00t! default div Avast!
                  Should now be:
                  for hero in heroes case hero.role when 'captain' div Yarr! when 'hacker' div w00t! default div Avast!

                  Errata type: code | Page number: 122

                  Query 5: In Chapter 5
                  What used to be:
                  if hero.role == 'captain' .msg Aye Captain! else if hero.role == 'hacker' && hero.name != 'Napman' .msg Who goes there? else .msg Avast!
                  Should now be
                  for (var i in heroes) { hero = heroes[i] if hero.role == 'captain' .msg Aye Captain! else if hero.role == 'hacker' && hero.name != 'Napman' .msg Who goes there? else .msg Avast! }

                  Errata type: Typo | Page number: 115

                  In Chapter 5, in Variables section
                  app.res.globals should be res.globals

                  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

                  Express Web Application Development +    Oracle APEX Cookbook : Second Edition =
                  50% Off
                  the second eBook
                  Price for both: £29.04

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

                  What you will learn from this book

                  • Understand the core concepts and objects that make up the Express framework and an Express app
                  • Create Jade-based views for Express apps and render them
                  • Create routes for an Express app and handle them
                  • Serve different kinds of responses and handle various kinds of errors
                  • Create dynamic apps using HTML forms, cookies, and sessions
                  • Learn about the Jade HTML templating language in detail
                  • Learn about the Stylus CSS pre-processor syntax and language in detail
                  • Customize and prepare your Express apps to make them production ready

                  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.

                  Approach

                  "Express Web Application Development" is a practical introduction to learning about Express. Each chapter introduces you to a different area of Express, using screenshots and examples to get you up and running as quickly as possible.

                  Who this book is for

                  If you are looking to use Express to build your next web application, "Express Web Application Development" will help you get started and take you right through to Express' advanced features. You will need to have an intermediate knowledge of JavaScript to get the most out of this book.

                  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
                  Resources
                  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