Learning Node, 2nd Edition

Book description

Take your web development skills from browser to server with Node—and learn how to write fast, highly scalable network applications on this JavaScript-based platform. Updated for the latest Node Long Term Support (LTS) and Node Current (6.0) releases, this hands-on edition helps you master Node’s core fundamentals and gain experience with several built-in and contributed modules.

Get up to speed on Node’s event-driven, asynchronous I/O model for developing data-intensive applications that are frequently accessed but computationally simple. If you’re comfortable working with JavaScript, this book provides many programming and deployment examples to help you take advantage of server-side development with Node.

  • Explore the frameworks and functionality for full-stack Node development
  • Dive into Node’s module system and package management support
  • Test your application or module code on the fly with Node’s REPL console
  • Use core Node modules to build web applications and an HTTP server
  • Learn Node’s support for networks, security, and sockets
  • Access operating system functionality with child processes
  • Learn tools and techniques for Node development and production
  • Use Node in microcontrollers, microcomputers, and the Internet of Things

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Who This Book Is For
    2. Book Structure
    3. Conventions Used in This Book
    4. Using Code Examples
    5. Safari® Books Online
    6. How to Contact Us
    7. Acknowledgments
  2. 1. The Node Environment
    1. Installing Node
    2. Saying Hello to the World with Node
      1. A Basic Hello World Application
      2. Hello World, Tweaked
      3. Node Command-Line Options
    3. Node Hosting Environments
      1. Hosting Node on Your Server, VPS, or Managed Host
      2. Cloud Hosting
    4. The Node LTS and Upgrading Node
      1. Node’s New Semantic Versioning
      2. Upgrading Node
    5. Node, V8, and ES6
    6. Advanced: Node C/C++ Add-ons
  3. 2. Node Building Blocks: Global Objects, Events, and Node’s Asynchronous Nature
    1. The global and process Objects
      1. The global Object
      2. The process Object
    2. Buffers, Typed Arrays, and Strings
      1. Buffer, JSON, StringDecoder, and UTF-8 Strings
      2. Buffer Manipulation
    3. Node’s Callback and Asynchronous Event Handling
      1. The Event Queue (Loop)
      2. Creating an Asynchronous Callback Function
      3. EventEmitter
      4. The Node Event Loop and Timers
    4. Nested Callbacks and Exception Handling
  4. 3. Basics of Node Modules and Node Package Manager (npm)
    1. An Overview of the Node Module System
      1. How Node Finds and Loads a Module
      2. Sandboxing and the VM Module
    2. An In-Depth Exploration of NPM
    3. Creating and Publishing Your Own Node Module
      1. Creating a Module
      2. Packaging an Entire Directory
      3. Preparing Your Module for Publication
      4. Publishing the Module
    4. Discovering Node Modules and Three Must-Have Modules
      1. Better Callback Management with Async
      2. Command-Line Magic with Commander
      3. The Ubiquitous Underscore
  5. 4. Interactive Node with REPL and More on the Console
    1. REPL: First Looks and Undefined Expressions
    2. Benefits of REPL: Getting a Closer Understanding of JavaScript Under the Hood
    3. Multiline and More Complex JavaScript
      1. REPL Commands
      2. REPL and rlwrap
      3. Custom REPL
    4. Stuff Happens—Save Often
    5. The Necessity of the Console
      1. Console Message Types, Console Class, and Blocking
      2. Formatting the Message, with Help from util.format() and util.inspect()
      3. Providing Richer Feedback with console and a Timer
  6. 5. Node and the Web
    1. The HTTP Module: Server and Client
    2. What’s Involved in Creating a Static Web Server
    3. Using Apache to Proxy a Node Application
    4. Parsing the Query with Query String
    5. DNS Resolution
  7. 6. Node and the Local System
    1. Exploring the Operating System
    2. Streams and Pipes
    3. A Formal Introduction to the File System
      1. The fs.Stats Class
      2. The File System Watcher
      3. File Read and Write
      4. Directory Access and Maintenance
      5. File Streams
    4. Resource Access with Path
    5. Creating a Command-Line Utility
    6. Compression/Decompression with ZLib
    7. Pipes and ReadLine
  8. 7. Networking, Sockets, and Security
    1. Servers, Streams, and Sockets
      1. Sockets and Streams
      2. TCP Sockets and Servers
      3. UDP/Datagram Socket
    2. Guards at the Gate
      1. Setting Up TLS/SSL
      2. Working with HTTPS
      3. The Crypto Module
  9. 8. Child Processes
    1. child_process.spawn
      1. child_process.exec and child_process.execFile
      2. child_process.fork
    2. Running a Child Process Application in Windows
  10. 9. Node and ES6
    1. Strict Mode
    2. let and const
    3. Arrow Functions
    4. Classes
    5. Promises with Bluebird
  11. 10. Full-Stack Node Development
    1. The Express Application Framework
    2. MongoDB and Redis Database Systems
      1. MongoDB
      2. Redis Key/Value Store
    3. AngularJS and Other Full-Stack Frameworks
  12. 11. Node in Development and Production
    1. Debugging Node Applications
      1. The Node Debugger
      2. Node Inspector
    2. Unit Testing
      1. Unit Testing with Assert
      2. Unit Testing with Nodeunit
      3. Other Testing Frameworks
    3. Keeping Node Up and Running
    4. Benchmark and Load Testing with Apache Bench
  13. 12. Node in New Environments
    1. Samsung IoT and GPIO
    2. Windows with Chakra Node
    3. Node for Microcontrollers and Microcomputers
      1. Fritzing
      2. Node and Adruino
      3. Node and Raspberry Pi 2
  14. Index

Product information

  • Title: Learning Node, 2nd Edition
  • Author(s): Shelley Powers
  • Release date: May 2016
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781491943076