Skip to content

Node.js Design Patterns Third Edition Exercise Solutions

Kelvin Peña edited this page Oct 3, 2024 · 184 revisions

In this page, we are collecting solutions for the exercises proposed in the book directly from the readers.

If you have completed some of them and want to share your solution, please edit this page and link your repository (or gist) with the solution.

This is the expected format for a new entry:

- [Solution](<LINK TO YOUR SOLUTION>) ([@<YOUR GITHUB USERNAME>](<YOUR GITHUB PROFILE URL>))

Make sure to use the preview mode, to validate that your entry will be shown correctly!

Thank you! 🤩

Chapter 1: The Node.js Platform

No exercise in this chapter

Chapter 2: The Module System

No exercise in this chapter

Chapter 3: Callbacks and Events

3.1 A simple event

3.2 Ticker

3.3 A simple modification

3.4 Playing with errors

Chapter 4: Asynchronous Control Flow Patterns with Callbacks

4.1 File concatenation

4.2 List files recursively

4.3 Recursive find

Chapter 5: Asynchronous Control Flow Patterns with Promises and Async/Await

5.1 Dissecting Promise.all()

5.2 TaskQueue with promises

5.3 Producer-consumer with promises

5.4 An asynchronous map()

Chapter 6: Coding with Streams

6.1 Data compression efficiency

6.2 Stream data processing

6.3 File share over TCP

6.4 Animations with Readable streams

Chapter 7: Creational Design Patterns

7.1 Console color factory

7.2 Request builder

7.3 A tamper-free queue

Chapter 8: Structural Design Patterns

8.1 HTTP client cache

8.2 Timestamped logs

8.3 Colored console output

8.4 Virtual filesystem

8.5 The lazy buffer

Chapter 9: Behavioral Design Patterns

Exercise 9.1 Logging with Strategy

Exercise 9.2 Logging with Template

Exercise 9.3 Warehouse item

Exercise 9.4 Logging with Middleware

Exercise 9.5 Queues with iterators

Chapter 10: Universal JavaScript for Web Applications

10.1 A matter of style

10.2 Proper data management

10.3 Pagination and search

No solution yet, please submit yours :)

10.4 A Universal... Blog!

No solution yet, please submit yours :)

Chapter 11: Advanced Recipes

11.1 Proxy with pre-initialization queues

11.2 Batching and caching with callbacks

11.3 Deep async cancelable

11.4 Compute farm

Chapter 12: Scalability and Architectural Patterns

12.1 A scalable book library

No solution yet, please submit yours :)

12.2 Exploring the Z-axis

12.3 Music addiction

No solution yet, please submit yours :)

Chapter 13: Messaging and Integration Patterns

13.1 History service with streams

13.2 Multiroom chat

No solution yet, please submit yours :)

13.3 Tasks that stop

No solution yet, please submit yours :)

13.4 Reliable task processing with ZeroMQ

No solution yet, please submit yours :)

13.5 Data aggregator

No solution yet, please submit yours :)

13.6 Worker status CLI

No solution yet, please submit yours :)

13.7 Worker status UI

No solution yet, please submit yours :)

13.8 Pre-initialization queues are back

No solution yet, please submit yours :)

13.9 Request/reply with Redis Streams

No solution yet, please submit yours :)

13.10 Kafka

No solution yet, please submit yours :)