Efficient Node.js

Book description

Take your web development skills from browser to server with Node.js, the popular backend framework used by more than 10 million developers at companies like Amazon, Netflix, and LinkedIn, to name just a few. If you're comfortable working with JavaScript, this practical guide from Samer Buna will show you how to effectively build and maintain even the most complex Node.js applications.

Following a hands-on, project-based approach, you'll move from key fundamentals to advanced concepts such as modules, packages, event-driven architecture, streams, child processes, scaling, testing, deployment, and much more—all while focusing on what actually matters in practice.

  • Explore Node.js modules and packages
  • Understand Node.js's event-driven architecture, streams, and child processes
  • Create, test, and maintain efficient and scalable Node.js applications

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Who Should Read This Book
    2. Why I Wrote This Book
    3. Conventions Used in This Book
    4. Using Code Examples
    5. O’Reilly Online Learning
    6. How to Contact Us
    7. Acknowledgments
  2. 1. Node Fundamentals
    1. Introduction
      1. The JavaScript Language
      2. Executing Node Code
      3. Using Built-in Modules
      4. Using Packages
      5. ES Modules
      6. Asynchronous Operations
    2. The Non-blocking Model
    3. Node Built-in Modules
    4. Node Packages
    5. Arguments Against Node
    6. Summary
  3. 2. Scripts and Modules
    1. Node CLI
      1. Options and Arguments
      2. Environment Variables
      3. REPL Mode
    2. Node Modules
      1. Resolving Modules
      2. Loading Modules
      3. Scoping Modules
      4. Executing Modules
      5. Caching Modules
    3. Summary
  4. 3. Asynchrony and Events
    1. Sync vs Async Handling
    2. Handler Functions
      1. Promises
      2. async/await
      3. An Analogy for Promises
    3. The Event Loop
    4. Event Emitters
      1. Asynchrony
      2. Errors
      3. Examples
    5. Summary
  5. 4. Errors and Debugging
    1. Throwing and Catching Errors
    2. Types of Errors
      1. Standard Errors
      2. System Errors
      3. Custom Errors
    3. Layered Error Management
    4. Debugging in Node
    5. Preventive Measures
      1. Code Quality Tools
      2. Immutable Objects
      3. Testing
      4. Code Reviews
    6. Summary
  6. 5. Package Management
    1. Introduction
    2. The npm Command
    3. Semantic Versioning
    4. Updating and Removing Packages
    5. Creating and Publishing Packages
    6. npm Run Scripts
    7. The npx Command
    8. Summary
  7. 6. Streams
    1. Introduction
    2. Using Streams
    3. Fundamentals of Streams
    4. Stream Pipeline
    5. Stream Events
    6. Paused and Flowing Modes
    7. Implementing Streams
      1. Writable Streams
      2. Readable Streams
      3. Duplex/Transform Streams
    8. Async Generators and Iterators
    9. Streams Object Mode
    10. Built-In Transform Streams
    11. Summary
  8. 7. Child Processes
    1. Introduction
    2. The spawn Function
    3. Shell Syntax and the exec Function
    4. The execFile Function
    5. The *Sync Functions
    6. The fork Function
    7. Summary
  9. 8. Testing Node
    1. Assertions and Runners
    2. Types of Tests
      1. Unit Tests
      2. Functional Tests
      3. Integration Tests
      4. End-to-End Tests
    3. Test Doubles
    4. Organizing and Filtering Tests
    5. Test-driven Development
    6. Continuous Integration
    7. Summary
  10. 9. Scaling Node
    1. Strategies of Scalability
    2. The Cluster Module
    3. Primary and Worker Processes
    4. Broadcasting Messages
    5. Increasing Availability
    6. Zero-downtime Restarts
    7. Handling State
    8. Process Managers
    9. Summary
  11. 10. Practical Node
    1. Code Quality Tools
      1. Prettier
      2. ESLint
      3. Other Tools
    2. Module Bundlers
    3. Task Runners
    4. Frameworks
    5. JavaScript Transpilers
    6. TypeScript
    7. Summary
  12. About the Author

Product information

  • Title: Efficient Node.js
  • Author(s): Samer Buna
  • Release date: January 2025
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781098145194