Preface
This book is about Express, the popular web framework used by thousands of Node.js developers around the world. It specifically covers the third major version of the framework, commonly referred to as Express 3.
Express has matured considerably since it was first released exactly four years ago. Today it is recognized as one of the best web frameworks for Node.js. Every day new developers from varied backgrounds and experience come to Express for developing their web apps. With its ever-growing popularity, it is about time we had a book on Express.
I wrote a tutorial on Express some time ago that became quite popular online, particularly with those new to Node.js and Express. Ever since, I had a dream of writing a book on Express, which would make no assumptions about the reader's prior experience and knowledge, and still be full of technical details wherever required. The book you are holding in your hands is that dream realized—a book on Express that is both beginner-friendly and technically deep at the same time.
This book covers everything a developer requires to get into serious web development using Express.
What this book covers
Chapter 1, What is Express?, is a beginner-friendly but technically solid introduction to Express and relevant topics for a strong base right at the start.
Chapter 2, Your First Express App, is a practical introduction to building an Express app covering the basics that form the basis of every Express app.
Chapter 3, Understanding Express Routes, explains routes in Express in great detail.
Chapter 4, Response From the Server, covers the various ways an Express app can respond to a request.
Chapter 5, The Jade Templating Language, covers the Jade syntax and its programming capabilities.
Chapter 6, The Stylus CSS Preprocessor, covers the Stylus syntax and its programming capabilities.
Chapter 7, Forms, Cookies, and Sessions, covers how to handle forms, and create cookies and sessions.
Chapter 8, Express in Production, covers important areas to make Express apps production-ready.
What you need for this book
Familiarity with JavaScript, the command line, and interest in the subject are all you need to get the most out of the book. Any new and relevant topics are introduced and explained in an easy-to-understand manner.
Who this book is for
This book is for anyone interested in knowing more about Express—either for developing web applications or just for technical knowledge in general. It is friendly enough for beginners to get started with, at the same time detailed enough to make an excellent refresher for those already familiar with Express who want to know more about it.
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The router
middleware is responsible for handling the requests to the app."
A block of code is set as follows:
app.get('/', function(req, res) { res.json({message: 'welcome'}); });
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
var not_found = function(req, res) {
res.status(404);
res.render('404', {title: 'Not Found'});
};
Any command-line input or output is written as follows:
$ sudo npm install express -g
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "The server will respond with the appropriate data type based on the Accept header."
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <feedback@packtpub.com>
, and mention the book title via the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.
Downloading the example code
You can download the example code fi les for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the fi les e-mailed directly to you.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <copyright@packtpub.com>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
Questions
You can contact us at <questions@packtpub.com>
if you are having a problem with any aspect of the book, and we will do our best to address it.