Welcome to Express in Action! This book aims to teach you everything about Express.js, the web framework that makes the powerful Node.js easy to use.
This book assumes you have intermediate JavaScript knowledge. This includes things like anonymous functions, closures, and callbacks.
This book is divided into three parts.
Part 1 is an introduction to Express and the shoulders it stands on. You might wonder: what is Express? What is its relationship to Node.js (and what is Node.js)? What can Express do? What can’t it do? All of these questions (and more) will be answered in the first three chapters. Part 1 aims to give you a strong conceptual understanding of the framework.
Armed with that strong knowledge, you’ll delve into part 2, which covers Express’s features in detail. In Part 1, we mention that Express has a feature called “routing.” In part 2, chapter 5 is dedicated to how routing, which allows you to map different requests to different request handler, really works. You’ll learn the ins and outs of routing and how to use Express with HTTPS. You’ll also explore Express 4’s new routers features, and build a couple of routing-centric applications. Another major feature of Express is its middleware stack (the focus of chapter 4) which is effectively an array of functions. In chapter 6, you use routing and middleware to build a web server that deals purely in JSON. The other big feature of Express is Views (explored in chapter 7). Views allow you to dynamically render HTML.
With a solid understanding of core Express from part 2, we’ll turn to part 3, which integrates Express with companion tools. As we’ll see, Express can’t do everything on its own—it needs to integrate with other tools in order to be truly useful (chapter 8). We can’t possibly go through all of the possible permutations of Express apps and their companions, but we’ll go through a number of common use cases that you can use to build web applications with the framework. Chapter 9 shows how to make your Express applications as robust as possible by testing; chapter 10 focuses on securing Express applications; chapter 11 shows how to deploy applications into the real world, and chapter 12 shows you how a mature Express application is put together.
And after that, you’ll close the book. You’ll be able to make your colleagues look like fools, at least when it comes to Express.js.
This book provides copious examples that show how you can make use of each of the topics covered. Source code in listings or in text appears in a fixed-width font like this to separate it from ordinary text. In addition, class and method names, object properties, and other code-related terms and content in text are presented using fixed-width font.
The code for the examples in this book is available for download from the publisher’s website at www.manning.com/express-in-action and on GitHub at https://github.com/EvanHahn/Express.js-in-Action-code/, where each chapter has a corresponding folder that has runnable versions of most of the code in this book.
There is also an unofficial repo that ports many of the book’s examples to TypeScript if you prefer that. It is at https://github.com/panacloud/learn-typed-express. It is unofficial, so your mileage may vary, but may be useful if you prefer TypeScript.
Purchase of Express in Action includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the author and from other users. To access the forum and subscribe to it, point your web browser to www.manning.com/express-in-action. This page provides information on how to get on the forum once you are registered, what kind of help is available, and the rules of conduct on the forum. It also provides links to the source code for the examples in the book, errata, and other downloads.
Manning’s commitment to our readers is to provide a venue where a meaningful dialog between individual readers and between readers and the author can take place. It is not a commitment to any specific amount of participation on the part of the author, whose contribution to the AO remains voluntary (and unpaid). We suggest you try asking the author challenging questions lest his interest strays!
The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.
Evan Hahn is a software engineer at Braintree where he works on JavaScript. He authors and contributes to a number of open source Node.js packages. He is made of flesh and bone.