Introduction

Summary

In this part, we’ll go over why this book was written, who might benefit from the book and how to use it most efficiently.

Why

Express.js is the most popular Node.js web framework yet. As of this writing (September of 2013), there are no books solely dedicated to it. Its official website has bits of insights for advanced Node.js programmers. However, I’ve found that many people — including those who go through the HackReactor program and come to my Node.js classes at General Assembly and pariSOMA — are interested in a definitive manual, one that would cover how all the different components of Express.js work together in real life. The goal of The Express.js Guide is to be that resource.

What This Book Is

Express.js Guide is an exhaustive book on one particular library. There are four distinct parts:

  • A hands-on quick start walkthrough to get a taste of the framework
  • An Express.js API 3.3.5 description which can be used as a reference
  • The best practices for code organization and patterns
  • Tutorials (meticulously depicted coding exercises) and examples (less detailed explanations of more complex apps) for the real world.

The Express.js Guide covers middleware, command-line interface and scaffolding, rendering templates, extracting params from dynamic URLs, parsing payloads and cookies, managing authentication with sessions, error handling, and prepping apps for production.

For more details on what the book covers, please refer to the Table of Contents.

What This Book is Not

This book is not an introduction to Node.js, nor is it a book that covers all aspects of building a modern day web application, e.g., websockets, databases, and (of course) front-end development. Also keep in mind that readers won’t find Express.js Guide aids for learning programming and/or JavaScript fundamentals here. This is not a beginners’ book.

For an introduction to Node.js, MongoDB, and front-end development with Backbone.js, you might want to take a look at Azat’s book Rapid Prototyping with JS: Agile JavaScript Development.

In the real world, and especially in Node.js development, due to its modularized philosophy, we seldom use just a single framework. In this book, we have tried to stick to Express.js and leave everything else out as much as possible, without compromising the usefulness of the examples. Therefore, we intentionally left out some important chunks of web development — for example databases, authentication and testing. Although these elements are present in tutorials and examples, they’re not explained in detail. For those materials, you could take a look at the books in the Related Reading and Resources section at the end of this book.

Who This Book is For

This book is for people fluent in programming and front-end JavaScript. To get the most benefits, readers must be familiar with basic Node.js concepts like process and global, and know core modules, including stream, cluster, and buffer.

If you’re thinking about starting a Node.js project, or about rewriting an existing one, and your weapon of choice is Express.js — this guide is for you! It will answer most of your “how” and “why” questions.

Notation

The code blocks will look like this: console.log('Hello reader!');. The terminal and console commands will have the corresponding prefixes $ and >.

If we mention and use a specific file or a folder, those names will be monospaced as well: index.js.

If there is a class or a module name in the text, it will be in bold type, e.g., superagent.

The new resources will only be hot-linked the first time we mention them.

Navigation

In PDF, EPUB/iPad and Mobi/Kindle versions of this book, you can use the Table of Contents for navigation. It contains internal links that readers can use to jump to the most interesting parts or chapters.

For faster navigation between parts, chapters and sections of this book, please use the book’s navigation pane which is based on the Table of Contents (the screenshot is below).

The Table of Contents pane in the Mac OS X Preview app.

The Table of Contents pane in the Mac OS X Preview app.

The PDF version of the book is suitable for printing on US Letter paper because all links are in the footnotes.

How to Use the Book

If you’re contemplating using Express.js or writing an app with it, read the whole book from beginning to end. However, if you’re somewhat familiar with the framework, jump straight to a question at hand. You can also skim through chapters if you like. The more advanced chapters deal with code organization and getting apps to production.

Examples

The book contains code snippets and run-ready examples. The latter are available in the GitHub repository at github.com/azat-co/expressjsguide. Additional examples can be found at http://github.com/azat-co/todo-express, github.com/azat-co/sfy-gallery and github.com/azat-co/hackhall.

The provided examples were written and tested only with the given specific versions of dependencies. Because Node.js and its ecosystem of modules are being developed rapidly, please pay attention to whether new versions have breaking changes. Here is the list of versions that we’ve used:

  • Express.js v3.3.5
  • Google Chrome Version 28.0.1500.95
  • Node.js v0.10.12
  • MongoDB v2.2.2
  • Redis v2.6.7
  • NPM v1.2.32

About the Author

Azat Mardanov: A software engineer, author and yogi.

Azat Mardanov: A software engineer, author and yogi.

Azat Mardanov has over 12 years of experience in web, mobile and software development. With a Bachelor’s Degree in Informatics and a Master of Science in Information Systems Technology degree, Azat possesses deep academic knowledge as well as extensive practical experience.

Currently, Azat works as a Senior Software Engineer at DocuSign, where his team rebuilds 50 million user product (DocuSign web app) using the tech stack of Node.js, Express.js, Backbone.js, CoffeeScript, Jade, Stylus and Redis.

Recently, he worked as an engineer at the curated social media news aggregator website Storify.com (acquired by LiveFyre). Before that, Azat worked as a CTO/co-founder at Gizmo — an enterprise cloud platform for mobile marketing campaigns, and he has undertaken the prestigious 500 Startups business accelerator program. Previously, he was developing mission-critical applications for government agencies in Washington, DC: National Institutes of Health, National Center for Biotechnology Information, Federal Deposit Insurance Corporation, and Lockheed Martin. Azat is a frequent attendee at Bay Area tech meet-ups and hackathons (AngelHack, and was a hackathon ’12 finalist with team FashionMetric.com).

In addition, Azat teaches technical classes at General Assembly and Hack Reactor, pariSOMA and Marakana (acquired by Twitter) to much acclaim.

In his spare time, he writes about technology on his blog: webAppLog.com which is number one in “express.js tutorial” Google search results. Azat is also the author of Express.js Guide, Rapid Prototyping with JS and Oh My JS.

Errata

Please help us make this book better by submitting GitHub issues to the expressjsguide repository: http://github.com/azat-co/expressjsguide/issues. Or you can submit issues via other means of communication listed below in the Contact Us section.

Contact Us

Let’s be friends on the Internet!

Other Ways to Reach Us

Share on Twitter with ClickToTweet link: http://clicktotweet.com/HDUx0, or just click:

“I’m reading Express.js Guide — the most popular Node.js framework’s manual by @azat_co #RPJS”