Node Cookbook
Third Edition
Actionable solutions for the full spectrum of Node.js 8 development
David Mark Clements
Mathias Buus
Matteo Collina
Peter Elger
BIRMINGHAM - MUMBAI
Node Cookbook
Third Edition
Copyright 2017 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 authors, 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 endeavoured 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: July 2012
Second edition: April 2014
Third edition: July 2017
Production reference: 2231117
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78588-008-7
www.packtpub.com
Credits
Authors David Mark Clements Mathias Buus Matteo Collina Peter Elger | Copy Editor Safis Editing |
Reviewers Bruno Joseph Dmello Daniel Durante Luca Maraschi | Project Coordinator Ritika Manoj |
Commissioning Editor Amarabha Banerjee | Proofreader Safis Editing |
Acquisition Editor Larissa Pinto | Indexer Francy Puthiry |
Content Development Editor Arun Nadar | Graphics Jason Monteiro |
Technical Editor Rashil Shah | Production Coordinator Nilesh Mohite |
Foreword
When I first heard about Node.js, it was back in 2011, and there were pretty much a handful of identifiable people and companies in the world using it. It was hipster back in those days; we started a company to specialize in Node, we started the Dublin Node Usergroup in May 2012, and out of 100 attendees on the first night, two shy hands rose when the group was asked "so how many of you are using Node?"
I met David Clements in the fall of 2012, when he had just published the first edition of the Node Cookbook. Eventually, David joined nearForm and many many adventures followed, including the fulfilling experience of our group helping the biggest users of Node.js to succeed.
As nearForm has grown, we have built the deepest and broadest collective of core engineers and app developers in the world, and it is with great pleasure that we have been able to enable and support David to write this book.
David and his group at nearForm are at the cutting edge of the Node project, and this book is a reflection of the deep learning and experience that David has amassed.
Cian Maidn,
nearForm CEO
About the Authors
David Mark Clements is a principal architect with nearForm, specializing in Node, frontend web, and JavaScript performance.
He assists multinationals and start-ups alike with architecture planning, creating and leading development teams, innovation projects, internal evangelism, training, and deep dive consultancy on all aspects of live systems (architecture, performance, infrastructure, and deployment).
David is also an avid open source enthusiast, and regularly speaks at various JavaScript and web conferences.
Node.js became a core component of his toolset (since version 0.4) due to its versatility, vast ecosystem, and the cognitive ease that comes with full-stack JavaScript. Being primarily self-taught, David Mark Clements has a potent curiosity that typically drives him to approach problems with a unique perspective.
Mathias Buus (@mafintosh) is a self-taught JavaScript hacker from Copenhagen.
He works full-time on open source projects and has been working with Node.js since its 0.2 days.
Mathias likes to work with P2P and distributed systems, and he is the author of more than 550 modules on npm, including some of the most popular ones for working with streams. In addition, he has spoken about mad science projects at various conferences around the world.
Matteo Collina is principal architect at nearForm. He holds a PhD from the University of Bologna with a thesis titled Application platforms for the Internet of Things. Matteo is the author and maintainer of more than 250 Node.js modules, totalling more than 50 million downloads per month. Some of his modules are the most performant, and he is an acknowledged Node.js performance expert. He has spoken at over 50 international conferences, including NodeConf.eu, Node.js Interactive, Node Summit, and QCon. He is also a member of the Node.js core technical committee.
Peter Elger is the CTO at nearForm, a consultancy specializing in enterprise digital transformation using the Node.js platform.
Formerly a physicist working on the JET nuclear fusion research project, Peter has worked across several industry verticals, including disaster recovery, telecommunications, and social media. Peter has been the cofounder and CTO of two companies prior to nearForm, and he holds degrees in theoretical physics and computer science. Based in Ireland, Peter spends his time consulting for clients, working on open source software, writing, and conference speaking.
About the Reviewers
Bruno Joseph Dmello works at Yapsody as a software engineer. He possesses almost 5 years of experience in web application development, serving industries such as entertainment, social media, enterprise, and IT services. He is a JavaScript enthusiast and dedicatedly worked on it for past 4 years. Apart from rare commits on https://github.com/bron10, he believes in contributing to open source by actually mentoring new technologies to beginners and involving them in open source communities. Bruno follows Kaizen and enjoys the freedom of architecting new things on the web. He also contributed his knowledge by authoring books such as Web Development in Node.js and Mongodb, What You Need to Know About Node.js (Free ebook) and by being a reviewer.
I would like to thank my parents and my fiancee, Erina, for the wonderful support and inspiration.
Daniel Durante is an avid coffee drinker, motorcyclist enthusiast, and rugby player. Daniel Durante has been programming since he was 12 years old, mostly involved with web development from PHP to Golang, while using PostgreSQL as his main choice of data storage.
Next page