Node.js Design Patterns book cover

Node.js Design Patterns

Second Edition

Master best practices to build modular and scalable server-side web applications

What's new

This new edition of Node.js Design patterns has been completely revamped in order to be even more relevant and up to date.

All the contents have been adapted to leverage the new features of Node.js version 6 and the code examples now extensively use many of the new features provided with EcmaScript 2015. Furthermore an entire new chapter about Universal JavaScript has been introduced.

Even if you read the first edition of this book you are going to love this upgrade!

What you get

100+ Working Examples

Learn by doing! With more than 100 working examples, you immediately put into practice everything you learn. Every code sample comes with a full step-by-step explanation, so you don't have to spend time to guess how things work.

11 Chapters

Every chapter will bring you one step closer to becoming a Node.js expert. From the basics of the Node.js architecture to how to scale and distribute your application, the book covers almost every aspect of Node.js development.

+500 Pages

A good learning experience can't be achieved by only throwing code and notions at the reader. Node.js Design Patterns comes with in-depth explanations and examples, so that even a novice can follow and immediately take advantage of advanced techniques.

The Journey

  • Chapter 1

    Welcome to the Node.js Platform

    This chapter serves as an introduction to the world of Node.js application design by showing the patterns at the core of the platform itself. It covers the Node.js ecosystem and its philosophy, a short introduction to Node.js version 6, ES2015, and the reactor pattern.

  • Chapter 2

    Node.js Essential Patterns

    This chapter introduces the first steps towards asynchronous coding and design patterns with Node.js discussing and comparing callbacks and the event emitter (observer pattern). This chapter also introduces the Node.js module system and the related module pattern.

  • Chapter 3

    Asynchronous Control Flow Patterns with Callbacks

    The third chapter introduces a set of patterns and techniques for efficiently handling asynchronous control flow in Node.js. This chapter teaches you how to mitigate the "callback hell" problem using plain JavaScript and the async library.

  • Chapter 4

    Asynchronous Control Flow Patterns with ES2015 and Beyond

    In this chapter we progress with the exploration of asynchronous control flows introducing Promises, Generators, and Async-Await.

  • Chapter 5

    Coding with Streams

    This chapter dives deep into one of the most important patterns in Node.js: streams. It shows you how to process data with transform streams and how to combine them into different layouts.

  • Chapter 6

    Design Patterns

    The sixth chapter deals with a controversial topic: traditional design patterns in Node.js. It covers the most popular conventional design patterns and shows you how unconventional they might look in Node.js. It also introduces the reader to some emerging design patterns that are specific only to JavaScript and Node.js.

  • Chapter 7

    Wiring Modules

    This chapter analyzes the different solutions for linking the modules of an application together. In this chapter, you will learn design patterns such as Dependency Injection and service locator.

  • Chapter 8 NEW

    Universal JavaScript for Web Applications

    This part of the book explores one of the most interesting capabilities of modern JavaScript web applications: being able to share application code between the frontend and the backend. Across this chapter we learn the basic principles of Universal JavaScript by building a simple web application with React, Webpack, and Babel.

  • Chapter 9

    Advanced Asynchronous Recipes

    The ninth chapter takes a problem-solution approach to show you how some common coding and design challenges can be solved with ready-to-use solutions.

  • Chapter 10

    Scalability and Architectural Patterns

    This chapter teaches you the basic techniques and patterns for scaling a Node.js application.

  • Chapter 11

    Messaging and Integration Patterns

    The final chapter presents the most important messaging patterns, teaching you how to build and integrate complex distributed systems using ZMQ and AMQP.

Download the entire Chapter 1 for free!

Discover the Node way, the reactor pattern and the module system

What people said

about the first edition

The Node.js Bible
Review on
Awesome. Information Gold
Review on
The code examples are simple and brilliant
Review on
Easily the best book on Node.js
Review on
Clear explanations of complex topics
Review on
An indispensable book for every node developer
Review on
Great book, which is rare these days.
Review on
If you are doing anything with Node, this book should be on your shelf/iPad/Kindle.
Review on

About the authors

Mario Casciaro

Mario Casciaro's picture

Mario Casciaro is a software engineer and entrepreneur, passionate about technology, science and open source knowledge. Mario graduated with a master's degree in software engineering and started his professional career at IBM where he worked for several years on different enterprise products such as Tivoli Endpoint Manager, Cognos Insight, and SalesConnect. Next, he moved to D4H Technologies, a growing SaaS company, to lead the development of a new bleeding-edge product for managing emergency operations in real-time. Currently, Mario is the co-founder and CEO of, a platform to help online projects raise funds through corporate sponsorship.

Mario is also the author of the first edition of Node.js Design Patterns (first edition).

Luciano Mammino

Luciano Mammino's picture

Luciano Mammino is a software engineer born in 1987, the same year that the Nintendo released Super Mario Bros in Europe, which by chance is his favorite video-game. He started coding at the age of 12 using his father's old Intel 386, provided only with the DOS operating system and the qBasic interpreter. After a master's degree in computer science he developed his programming skills mostly as a web developer working mainly as freelancer for companies and startups all around Italy. After a start-up parenthesis of 3 years as CTO and co-founder of in Italy and in Ireland, he decided to relocate in Dublin to work as senior PHP engineer at Smartbox.

He loves developing open source libraries and working with frameworks such as Symfony and Express. He is convinced that the JavaScript fame is still at the very beginning and that this technology will have a huge impact in the future of most of the web-and mobile-related technologies. For this reason, he spends most of his free time improving his knowledge of JavaScript and playing with Node.js.

Buy the Book

Available in paperback and electronic format