Get to the forefront of server-side JavaScript programming by writing compact, robust, fast, networked Node applications that scale. Ready to take JavaScript beyond the browser, explore dynamic languages features and embrace evented programming? Explore the fun, growing repository of Node modules provided by npm. Work with multiple protocols, load-balanced RESTful web services, express, ØMQ, Redis, CouchDB, and more. Develop production-grade Node applications fast.

Buy Now

Select a DRM-free Format:

In Stock
In Stock
In Stock
Buy the eBook and get these DRM-free formats delivered immediately:
  • epub (for iPhone/iPad, Android, eReaders)
  • mobi (for Kindle)
  • PDF
We can automatically send them to your Dropbox. (You'll need to log in to enable these options.)

About this Book

  • 148 pages
  • Published:
  • Release: P1.0 (2013-11-20)
  • ISBN: 978-1-93778-573-4

JavaScript is the backbone of the modern web, powering nearly every web app’s user interface. Node.js is JavaScript for the server. This book shows you how to develop small, fast, low-profile, useful, networked applications. You’ll write asynchronous, non-blocking code using Node’s style and patterns. You’ll cluster and load balance your services with Node core features and third-party tools. You’ll work with many protocols, creating RESTful web services, TCP socket clients and servers, and more.

This short book packs a hefty dose of Node.js. You’ll test your code’s functionality and performance under load. You’ll learn important aspects of Node development—from its architecture and core, to its ecosystem of third-party modules. You’ll discover how Node pairs a server-side event loop with a JavaScript runtime to produce screaming fast, non-blocking concurrency. Through a series of practical programming domains, you’ll use the latest available ECMAScript Harmony features and harness key Node classes such as EventEmitter and Stream. Throughout the book, you’ll develop real programs that are small, fast, low-profile, and useful.

Get ready to join a smart community that’s rapidly advancing the state of the art in web development.

What You Need

  • Latest stable release of Node.js, this book was written with 0.12.x in mind.
  • The ØMQ (ZeroMQ) library, version 3.2 or higher.

Contents and Extracts

  • Acknowledgments
  • Preface
    • Why Node.js the Right Way
    • What’s in This Book
    • What This Book Is Not
    • Code Examples and Conventions
    • Online Resources
  • Getting Started
    • Node’s Niche
    • How Node Applications Work
    • Aspects of Node.js Development
    • Get Node.js
  • Wrangling the File System
    • Programming for the Node.js Event Loop
    • Spawning a Child Process
    • Capturing Data from an EventEmitter
    • Reading and Writing Files Asynchronously
    • The Two Phases of a Node Program
    • Wrapping Up
  • Networking with Sockets excerpt
    • Listening for Socket Connections
    • Implementing a Messaging Protocol
    • Creating Socket Client Connections
    • Testing Network Application Functionality
    • Extending Core Classes in Custom Modules
    • Wrapping Up
  • Robust Messaging Services
    • Advantages of ØMQ
    • Importing External Modules with npm
    • Message-Publishing and -Subscribing
    • Responding to Requests
    • Routing and Dealing Messages
    • Clustering Node.js Processes
    • Pushing and Pulling Messages
    • Wrapping Up
  • Accessing Databases
    • Advantages of CouchDB
    • Creating a Package
    • Making RESTful Requests
    • Importing Real Data
    • Unit Testing with Nodeunit
    • Throttling Node.js
    • Querying Data with Mapreduce Views
    • Wrapping Up
  • Scalable Web Services
    • Advantages of Express
    • Serving APIs with Express
    • Writing Modular Express Services
    • RESTful APIs with Promises
    • Yielding Control with Generators
    • Using Generators with Promises
    • Wrapping Up
  • Web Apps excerpt
    • Storing Express Sessions in Redis
    • Creating a Single-Page Web Application
    • Authenticating with Passport
    • Authorizing APIs with Custom Middleware
    • Creating Authenticated APIs
    • Client-Side MVC
    • Wrapping Up
    • Parting Thoughts

About the Author

Jim R. Wilson is a software engineer at Google. He’s contributed to several open-source projects including corridor, HBase, MediaWiki, and Node.js. In addition to coding and writing, Jim is a speaker and co-author of Seven Databases in Seven Weeks.

Comments and Reviews

  • Node.js the Right Way really is the right way to get a fast start with modern serverside JavaScript programming. It goes far beyond the basic mechanics of JavaScript and Node and shows you what really goes into making a quality server-side application.

    —Allen Wirfs-Brock Project editor, ECMAScript Language Specification
  • If you’re just getting started with Node, skip everything else––this is the only book you’ll need.

    —Rick Waldron Software engineer, Boucoup, LLC
  • Finally, a book that teaches that Node.js is much more than a bare-bones webscale application server for hipsters.

    —Eric Redmond Coauthor of Seven Databases in Seven Weeks
  • Node.js the Right Way is a great read that quickly demonstrates Node’s flexibility and power. It’s perfect for any JavaScript developer who’s interested in exploring the world of server infrastructure.

    —Xavi Ramirez Baydin, Inc.
  • Node.js the Right Way is the right book to read. Skipping “Hello World” in favor of applicable examples, Wilson delivers a comprehensive introduction that is detailed yet engaging.

    —Daniel Renfro Lead software engineer Vistaprint
  • This book is a fantastic way to explain Node. I even used some of Jim’s example code in a personal project (especially Chapter 7).

    —Mitchell Foley Software engineer Google