Node.js Design Patterns - Luciano Mammino - E-Book

Node.js Design Patterns E-Book

Luciano Mammino

0,0
39,59 €

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

Mehr erfahren.
Beschreibung

Node.js underpins much of modern web development, reliably powering APIs and full-stack apps across all industries. Authors Luciano Mammino and Mario Casciaro offer a practical guide that unpacks the JavaScript runtime so you can write reliable, high-performance Node.js apps.
Building on the highly rated third edition, this new edition adds fresh case studies and the latest Node.js developments: newer APIs and libraries, ESM improvements, practical security and production tips, and guidance on using Node.js with TypeScript. It also introduces a new chapter on testing that gives you a full introduction to testing philosophy and practical guidance on writing unit, integration, and end-to-end tests, giving you the confidence to write functional, stable, and reliable code.
Real-world, end-to-end examples throughout the book show how to build microservices and distributed systems with Node.js, integrating production-proven technologies such as Redis, RabbitMQ, LevelDB, and ZeroMQ, the same components you’ll find in scalable deployments at companies of all sizes. End-of-chapter exercises consolidate your understanding.
By the end of this Node.js book, you’ll have the design patterns, mindset, and hands-on skills every serious Node.js professional needs to confidently architect robust, efficient, and maintainable applications.

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

EPUB
MOBI

Seitenzahl: 1158

Veröffentlichungsjahr: 2025

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.



Node.js Design Patterns

Fourth Edition

Level up your Node.js skills and design production-grade applications using proven techniques

Luciano Mammino

Mario Casciaro

Node.js Design Patterns

Fourth Edition

Copyright © 2025 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 or its dealers and distributors, will be held liable for any damages caused or alleged to have been 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.

Portfolio Director: Ashwin Nair

Relationship Lead: Aaron Lazar

Project Manager: Ruvika Rao

Content Engineer: Nisha Cleetus

Technical Editor: Rohit Singh

Copy Editor: Safis Editing

Indexer: Tejal Soni

Proofreader: Nisha Cleetus

Production Designer: Prashant Ghare

Growth Lead: Priyadarshini Sharma

First published: December 2014

Second edition: July 2016

Third edition: June 2020

Fourth edition: September 2025

Production reference: 2121125

Published by Packt Publishing Ltd.

Grosvenor House

11 St Paul’s Square

Birmingham

B3 1RB, UK.

ISBN 978-1-80323-894-4

www.packtpub.com

Foreword 1

When the first edition of Node.js Design Patterns was published, the server-side JavaScript landscape looked very different from today. Node.js itself was still only a few years old, although it was already being deployed at scale by numerous large companies. Developers were more likely to be using callbacks and CommonJS than Promises and ECMAScript modules. In Node.js Design Patterns, Mario covered the important topics for building applications with Node.js at the time.

Since that time, a lot has changed in the JavaScript ecosystem. New language features such as async/await have fundamentally changed how code is written. JavaScript code is no longer confined to a single thread. Node.js is regularly improving its compatibility with the web platform, as well as adding new functionality of its own. New code is often written in TypeScript, and developers expect to be able to run it without having to transpile it first. Node.js is no longer considered new and shiny, but rather boring and dependable — as any popular, mature software project should be.

Keeping up with the evolution of Node.js can be challenging. As a long-time Node.js contributor and production user, I can attest to that. Fortunately for the community, Node.js Design Patterns has continued to prove itself up to the task. Second and third editions of the book have been published along the way, with Luciano joining as a co-author. Now in its fourth edition, I still think this book covers the important topics for building applications with Node.js.

I think this book has something for Node.js developers of all experience levels. For developers who are new to Node.js, this book can be used as a good starting point on their journey. These readers will learn about some of the history, design choices, and architecture of Node.js, before moving on to common patterns for building and scaling applications. Additionally, this edition of the book includes a chapter on testing with the new Node.js test runner. As the original author of Node’s test runner, this chapter piqued my interest. Not only is the test runner explored in detail, but the chapter also does a great job of covering generic testing philosophies that can be applied to other technologies.

More experienced Node.js developers can use the material in this book to keep up with the latest developments in the ecosystem, and will find this book to be an overall handy reference. However, this book doesn’t just focus on Node.js in isolation. There is also coverage of important tools for successfully running Node.js in production, such as Nginx and Kubernetes, which I think advanced users will find appealing.

No matter where you are on your software journey, I sincerely hope you enjoy this book. As you explore its pages, remember that Node.js has always been about more than just technology. It is also about community and collaboration between countless developers around the world. This book is both a product of, and a tribute to that community.

I am excited to see how you, the reader, will continue to carry the Node.js ecosystem forward!

Colin J. Ihrig

Node.js Contributor

Foreword 2

Performance is not an afterthought in Node.js development; it is a design principle. How can we build applications that are not just functional but blazingly fast? How do we structure code that can handle millions of requests without breaking a sweat? These questions have driven my work for years, and I am thrilled to introduce a book that provides concrete answers: this exceptional guide to Node.js Design Patterns.

The authors have created something remarkable here: a comprehensive resource that not only teaches patterns but also shows you how to think about performance and architecture from day one. When I started writing Fastify, aiming for that astonishing speed of 47k requests per second, I learned that the secret was not in clever tricks but in understanding the fundamental patterns that make Node.js tick. This book captures that essence perfectly.

The journey begins with understanding the Node.js platform itself and its module system. These foundational chapters set the stage for everything that follows. The progression through callbacks, events, and asynchronous control flow patterns reflects the evolution every Node.js developer experiences. The authors wisely dedicate two full chapters to async patterns, acknowledging that mastering asynchronous programming is crucial for Node.js success.

I am particularly excited about Chapter 6, Coding with Streams. You are probably using streams already, even if you do not realize it. Streams are the bedrock of Node.js, present everywhere from HTTP requests to file operations. Yet they remain one of the most misunderstood APIs in our ecosystem. Almost every developer thinks streams are complex until they understand the patterns behind them. This chapter demystifies streams in a way that will make you wonder why you ever found them difficult. The authors show you not just how to use streams, but how to think in streams and how to build pipelines that can process gigabytes of data with minimal memory footprint.

The design-pattern chapters that follow (Creational, Structural, and Behavioral) translate classic software engineering concepts to the Node.js context. This is not a mechanical port of Gang of Four patterns; it is a thoughtful adaptation that respects the event-driven, asynchronous nature of Node.js. Chapter 10 on testing is essential reading because performance without reliability is meaningless.

What truly sets this book apart are the final chapters. Chapter 12 on scalability and architectural patterns addresses the questions I hear most often: How do we scale? Should we use microservices or a modular monolith? The authors provide practical guidance based on real-world experience. Chapter 13 on messaging and integration patterns is particularly relevant in today’s distributed systems landscape, where Node.js applications rarely exist in isolation.

The patterns presented here are not academic exercises. They are the same patterns we use at Platformatic to build enterprise-grade Node.js applications. They power npm, handling millions of package downloads daily. They will also help you reduce your cloud bill by writing more efficient code.

Node.js is resilient, popular, and more relevant than ever. Despite claims of its decline, Node.js continues to thrive, and books like this are the reason why. They elevate our community’s knowledge, helping developers move from “it works” to “it works at scale.”

Whether you are building your first Node.js application or architecting microservices for millions of users, this book will transform how you think about Node.js development. The cost of not understanding these patterns is too high, literally in terms of your AWS bill and figuratively in terms of technical debt.

Dive in, embrace the patterns, and remember: we are not just writing code; we are building the future of the web. And with the knowledge in this book, you will be building it at ludicrous speed.

Matteo Collina

Co-Founder & CTO at Platformatic.dev

Chair of the Node.js Technical Steering Committee

Lead Maintainer of Fastify

P.S. If after reading this book your application is not at least 2x faster, you are probably not measuring correctly. Remember: always benchmark!

Contributors

About the authors

Luciano Mammino began his coding journey at the age of 12 on his father’s old i386, and he hasn’t stopped since. With over 15 years of experience in the software industry, he now serves as a senior architect at fourTheorem (fourtheorem.com), where he empowers global clients to fully leverage AWS and serverless technologies. As an AWS Serverless Hero and Microsoft MVP, Luciano is recognized for his expertise and contributions to the tech community. An active international speaker, he has delivered over 160 talks at conferences and meetups worldwide, sharing his knowledge and passion for cutting-edge technology. You can stay in touch with Luciano and explore his many passions on his blog at loige.co.

The biggest thanks of all goes to Mario Casciaro for inviting me into such an amazing project. Looking back over the past 11 years, it is incredible to think that this book, in its first edition, was what first introduced me to Node.js. Life came full circle when I had the privilege of becoming a co-author for the following three editions. It has been a fantastic journey, and I have learned and grown immensely while working together. I truly hope we will have many more opportunities to collaborate in the future.

Thanks to the entire Packt team and to everyone who has worked hard to bring this book to life across all four editions.

Thanks to our incredible reviewers, Maksim and Nick, along with all the early readers who provided feedback. This new edition would not be the same without your support and guidance.

A heartfelt thanks to Stefan Judis, Ludovico Besana, and Michael Di Prisco for generously sharing your expertise while reviewing the new chapter on testing. Your insightful comments and suggestions have taught me a great deal and have helped shape this new part of the book into something I am confident every reader will truly enjoy.

To our readers: so many of you have shared meaningful stories about how the previous editions of this book have had a positive impact on your career. That is the fuel that keeps us motivated to ensure it remains an up-to-date and valuable resource for every Node.js developer. I am grateful to everyone who has taken the time to leave a review, recommend the book to a friend or colleague, or offer feedback on what could be improved.

Thanks to my colleagues at fourTheorem, and especially to Fiona, Peter, and Eoin, for always trusting and empowering me even beyond the boundaries of my role.

A huge thank you to my family, whose love, encouragement, and belief in me have been my anchor and my driving force in chasing and achieving my goals.

And finally, a very special thanks to my lovely wife, Francesca. None of this would have been possible without you. Here’s to all the chapters still waiting to be written in our shared story.

Mario Casciaro is a software architect, technology leader, and entrepreneur with a long career in building and scaling software products for mission-critical industries. Throughout his career, he has held roles ranging from software engineer to team leader to CTO. His passion for software and technology has led him to develop multiple side projects, launch a start-up, and, of course, write the bestselling book Node.js Design Patterns. His proudest moment is seeing his software being used for astronaut rescue operations.

I want to thank everyone who made this edition possible, and especially Luciano. Without him, and his relentless dedication and knowledge, this edition simply wouldn’t exist. Thank you, Luciano.

About the reviewers

Nicholas Ramsbottom is a software developer based in London with experience in e-commerce, publishing, and marketing. He can be found swimming, cycling, and brewing beer when not coding.

Maksim Sinik is a senior engineering manager at TrustLayer, where he leads engineering teams developing innovative insurance compliance solutions using cloud computing and microservices architecture. As a core team member of Fastify, the high-performance Node.js web framework, he actively contributes to one of the fastest-growing open-source projects in the ecosystem. With deep expertise in Node.js, MongoDB, and DevOps practices, Maksim combines technical leadership with a passion for building scalable, reliable systems and leveraging technology to solve real-world problems and create positive impact worldwide.

Beta readers

Péter Szabó

Changho Lee

Nader