Advanced Express Web Application Development - Andrew Keig - E-Book

Advanced Express Web Application Development E-Book

Andrew Keig

0,0
31,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Building an Express application that is reliable, robust, maintainable, testable, and can scale beyond a single server requires a bit of extra thought and effort. Express applications that need to survive in a production environment will need to reach out to the Node ecosystem and beyond, for support.You will start by laying the foundations of your software development journey, as you drive-out features under test. You will move on quickly to expand on your existing knowledge, learning how to create a web API and a consuming client. You will then introduce a real-time element in your application.Following on from this, you will begin a process of incrementally improving your application as you tackle security, introduce SSL support, and how to handle security vulnerabilities. Next, the book will take you through the process of scaling and then decoupling your application. Finally, you will take a look at various ways you can improve your application's performance and reliability.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 132

Veröffentlichungsjahr: 2013

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Advanced Express Web Application Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Foundations
Feature set
Installation
package.json
Testing Express with Mocha and SuperTest
Feature: Heartbeat
Continuous testing with Mocha
Code coverage with Mocha and JSCoverage
Configuring Express with Nconf
Extracting routes
404 handling middleware
Logging middleware
Logging with Winston
Task automation with Grunt
Summary
2. Building a Web API
Persisting data with MongoDB and Mongoose
GitHub tokens
Feature: Create a project
Feature: Get a project
Feature: Edit a project
Feature: Delete a project
Feature: List projects
GitHub API
Feature: List repositories
Feature: List commits
Feature: List issues
Validating parameters with param middleware
Route improvements
Summary
3. Templating
Server-side templating
Feature: Master Page
Package management with Bower
Templates
Client-side development with Backbone.js
Feature: List projects
Feature: List repositories
Feature: Create a project
Feature: Edit a project
Feature: Delete a project
Feature: List commits
Feature: List issues
Summary
4. Real-time Communication
Caching data with Redis
Populating Redis
Socket.IO
Socket.IO on the client
Scheduling Redis population
Summary
5. Security
Setting up Passport
Acceptance testing with Cucumber and Zombie.js
Feature: Authentication
Scenario: User logs in successfully
Scenario: User logs out successfully
Securing our site with HTTPS
Sharing Express sessions with Socket.IO
Cross-site request forgery
Improving security with HTTP headers and helmet
Summary
6. Scaling
Scaling Express sessions with Redis
Scaling Socket.IO with Redis
Scaling Express horizontally
vision-core
vision-api
vision-worker
vision-web
Vertical scale with Cluster
Balancing load with Hipache
Summary
7. Production
Error handling, domains, and crash-only design
Redis sessions
SSL termination
Caching
Favicon
Minification
Compression
Logging
Summary
Index

Advanced Express Web Application Development

Advanced Express Web Application Development

Copyright © 2013 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: November 2013

Production Reference: 1181113

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78328-249-4

www.packtpub.com

Cover Image by Rima Pawooskar (<[email protected]>)

Credits

Author

Andrew Keig

Reviewers

Dave Poon

Artem Vovsya

Acquisition Editors

Erol Staveley

Owen Roberts

Commissioning Editors

Subho Gupta

Sharvari Tawde

Technical Editors

Kapil Hemnani

Tarunveer Shetty

Copy Editors

Sarang Chari

Brandt D'Mello

Lavina Pereira

Project Coordinator

Sherin Padayatty

Proofreader

Simran Bhogal

Indexer

Tejal Daruwale

Production Coordinator

Aparna Bhagat

Cover Work

Aparna Bhagat

About the Author

Andrew Keig is a London based web developer who has been building web applications since 2000. He is the author of Packt's Instant RabbitMQ Messaging Application Development How-to. Andrew has a degree in Computing and blogs at blog.airasoul.net on topics he is passionate about, such as Node.js, REST, Web APIs, and behaviour-driven development. He also contributes to various Node.js open source projects. He is a director at Airasoul, which specializes in the design and build of scalable, RESTful, specification-driven, and real-time web-based applications on the Node.js stack. He is also the co-founder of openue.com, a property search startup.

This book is the culmination of my experience working on multiple Node.js projects. I thank those who worked with me: Johnny Hall, Mehdi Avdi, Jozz Hart, Keith Bowditch, Lee Wilson, and 
Craig Strong.

I would like to thank TJ. Holowaychuk, the author of Express, the author of Node.js, Ryan Dahl, Node's current custodian Isaac Z. Schlueter, and the thousands of Node module developers who have all contributed to making Node.js an awesome space to work in.

Finally, I would also like to thank my reviewers: Dave Poon, and Artem Vovsya for their invaluable input and the team at Packt Publishing for their support.

Finally, thank you to all my family.

About the Reviewers

Dave Poon is a web developer and designer based in Sydney. He started his career as a freelance graphic and web designer in 1998 and worked with web development agencies and medium-size enterprises. After graduating from Central Queensland University with a degree in Multimedia Studies and Master's degree in IT, he began his love affair with Drupal, and worked for a variety of companies that use Drupal.

Currently, he is a Design Lead at Suncorp, one of the biggest financial institutions in Australia. He is also the co-founder of Erlango (http://erlango.com), a digital product design startup, located in Sydney and Hong Kong, that creates user-centered digital products and tools for designers and users.

He is also the author of Packt's Drupal 7 Fields/CCK.

I would like to thank my wife Rita for her endless patience 
and support. Without her, what I do would be meaningless.

And also I would like to thank my father for his 
continued encouragement.

Artem Vovsya has been writing software since 2006, when he started working as a Delphi developer for a little software company. He got his Bachelor's degree in Computer Engineering. He tried his hand at being a Delphi and .NET developer. Two years ago, he fell in love with Node.js, and now he's writing frontend and backend code completely in JavaScript.

Currently he is a frontend developer at Yandex, the leading Russian search engine.

www.PacktPub.com

Support files, eBooks, discount offers and more

You might want to visit www.PacktPub.com for support files and downloads related to your book.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

http://PacktLib.PacktPub.com

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books. 

Why Subscribe?

Fully searchable across every book published by PacktCopy and paste, print and bookmark contentOn demand and accessible via web browser

Free Access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.

This book is dedicated to my wife Rima and beloved son Indie.

Thank you both for your love and understanding.

Preface

Building an Express application that is reliable, robust, maintainable, testable, and can scale beyond a single server requires a bit of extra thought and effort. Express applications that need to survive in a production environment will need to reach out to the Node ecosystem and beyond for support. Advanced Express Web Application Development aims to deliver a working real-world, single-page application that can meet these goals and allow us the opportunity to explore the more advanced features of Express.

What this book covers

Chapter 1, Foundations, lays the foundation as we put in place a skeleton application; we introduce testing and automation practices that we will use to build our example single-page application.

Chapter 2, Building a Web API, helps in building a web API that our application will consume.

Chapter 3, Templating, helps you create a consuming client with a working web API in place and explore the client- and server-side templating.

Chapter 4, Real-time Communication, helps us to add real-time updates to content displayed in our single-page application.

Chapter 5, Security, guides us to secure our application as we look at authentication, security vulnerabilities, and SSL.

Chapter 6, Scaling, demonstrates scaling our Express application using Redis, and also looks at the benefits of decoupling an Express application.

Chapter 7, Production, examines real-world Express deployment issues such as performance, robustness, and reliability.

What you need for this book

In order to create and run the examples in this book, you will need a Mac or PC running Windows or Linux; you can use any text editor. This book will provide you with instructions on installing Node.js, Express, and various dependencies including Redis and MongoDB.

Who this book is for

If you are an experienced JavaScript developer who wants to build highly scalable, real-world applications using Express, this book is ideal for you. This book is an advanced title and assumes that the reader has some experience with Node.js, JavaScript MVC web development frameworks, and has at least heard of Express before. The reader should also have a basic understanding of Redis and MongoDB. This book is not a tutorial on node but aims to explore some of the more advanced topics you will encounter when developing, deploying, and maintaining an Express web application.

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 <[email protected]>, 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.

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.

Downloading the example code

You can download the example code files 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 files e-mailed directly to you.

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 <[email protected]> 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 <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.

Chapter 1. Foundations

Advanced Express Web Application Development will guide you through the process of building a nontrivial, single-page application using Express.

Express is a fast, unopinionated, minimalist, and flexible web application framework for Node.js written by TJ. Holowaychuk. It was inspired by Sinatra, a web framework for Ruby. Express provides a robust set of features for building single, multi-page, and hybrid web applications and has quickly become the most popular web development framework for node. Express is built on top of an extensible HTTP server framework—also developed by TJ. Holowaychuk—called Connect. Connect provides a set of high performance plugins known as middleware. Connect includes over 20 commonly used middleware, including a logger, session support, cookie parser, and more.

This book will guide you through the process of building a single-page application called Vision; a dashboard for software development projects that integrates with GitHub to give you a single-screen snapshot of your software development projects issues and commits. This project will allow us to demonstrate the advanced features Express has to offer and will give us the opportunity to explore the kind of issues encountered in a commercial development and production deployment of a node/Express application.

Feature set

We will now begin the process of building a Vision application. We will start from scratch with a test-first approach. Along the way, we will explore some best practices and offer tips for when developing web applications with node and Express.

The Vision application will include the following features: