Node.js 8 the Right Way

Book description

Node.js is the platform of choice for creating modern web services. This fast-paced book gets you up to speed on server-side programming with Node.js 8, as you develop real programs that are small, fast, low-profile, and useful. Take JavaScript beyond the browser, explore dynamic language features, and embrace evented programming.Harness the power of the event loop and non-blocking I/O to create highly parallel microservices and applications. This expanded and updated second edition showcases the latest ECMAScript features, current best practices, and modern development techniques.

JavaScript is the backbone of the modern web, powering nearly every web app's user interface. Node.js is JavaScript for the server. This greatly expanded second edition introduces new language features while dramatically increasing coverage of core topics. Each hands-on chapter offers progressively more challenging topics and techniques, broadening your skill set and enabling you to think in Node.js.

Write asynchronous, non-blocking code using Node.js's style and patterns. Cluster and load balance services with Node.js core features and third-party tools. Harness the power of databases such as Elasticsearch and Redis. Work with many protocols, create RESTful web services, TCP socket clients and servers, and more. Test your code's functionality with Mocha, and manage its life cycle with npm. Discover how Node.js pairs a server-side event loop with a JavaScript runtime to produce screaming fast, non-blocking concurrency. Through a series of practical programming domains, use the latest available ECMAScript features and harness key Node.js classes and popular modules. Create rich command-line tools and a web-based UI using modern web development techniques.

Join the smart and diverse community that's rapidly advancing the state of the art in JavaScript development.

What You Need:

  • Node.js 8.x
  • Operating system with bash-like shell
  • OMQ (pronounced "Zero-M-Q") library, version 3.2 or higher
  • Elasticsearch version 5.0 or higher
  • jq version 1.5 or higher
  • Redis version 3.2 or higher
  • Publisher resources

    View/Submit Errata

    Table of contents

    1.  Acknowledgments
    2.  Preface
      1. Why Node.js the Right Way?
      2. What’s in This Book
      3. What This Book Is Not
      4. Code Examples and Conventions
      5. Online Resources
    3. Part I. Getting Up to Speed on Node.js 8
      1. 1. Getting Started
        1. Thinking Beyond the web
        2. Node.js’s Niche
        3. How Node.js Applications Work
        4. Aspects of Node.js Development
        5. Installing Node.js
      2. 2. Wrangling the File System
        1. Programming for the Node.js Event Loop
        2. Spawning a Child Process
        3. Capturing Data from an EventEmitter
        4. Reading and Writing Files Asynchronously
        5. The Two Phases of a Node.js Program
        6. Wrapping Up
      3. 3. Networking with Sockets
        1. Listening for Socket Connections
        2. Implementing a Messaging Protocol
        3. Creating Socket Client Connections
        4. Testing Network Application Functionality
        5. Extending Core Classes in Custom Modules
        6. Developing Unit Tests with Mocha
        7. Wrapping Up
      4. 4. Connecting Robust Microservices
        1. Installing ØMQ
        2. Publishing and Subscribing to Messages
        3. Responding to Requests
        4. Routing and Dealing Messages
        5. Clustering Node.js Processes
        6. Pushing and Pulling Messages
        7. Wrapping Up
    4. Part II. Working with Data
      1. 5. Transforming Data and Testing Continuously
        1. Procuring External Data
        2. Behavior-Driven Development with Mocha and Chai
        3. Extracting Data from XML with Cheerio
        4. Processing Data Files Sequentially
        5. Debugging Tests with Chrome DevTools
        6. Wrapping Up
      2. 6. Commanding Databases
        1. Introducing Elasticsearch
        2. Creating a Command-Line Program in Node.js with Commander
        3. Using request to Fetch JSON over HTTP
        4. Shaping JSON with jq
        5. Inserting Elasticsearch Documents in Bulk
        6. Implementing an Elasticsearch Query Command
        7. Wrapping Up
    5. Part III. Creating an Application from the Ground Up
      1. 7. Developing RESTful Web Services
        1. Advantages of Express
        2. Serving APIs with Express
        3. Writing Modular Express Services
        4. Keeping Services Running with nodemon
        5. Adding Search APIs
        6. Simplifying Code Flows with Promises
        7. Manipulating Documents RESTfully
        8. Emulating Synchronous Style with async and await
        9. Providing an Async Handler Function to Express
        10. Wrapping Up
      2. 8. Creating a Beautiful User Experience
        1. Getting Started with webpack
        2. Generating Your First webpack Bundle
        3. Sprucing Up Your UI with Bootstrap
        4. Bringing in Bootstrap JavaScript and jQuery
        5. Transpiling with TypeScript
        6. Templating HTML with Handlebars
        7. Implementing hashChange Navigation
        8. Listing Objects in a View
        9. Saving Data with a Form
        10. Wrapping Up
      3. 9. Fortifying Your Application
        1. Setting Up the Initial Project
        2. Managing User Sessions in Express
        3. Adding Authentication UI Elements
        4. Setting Up Passport
        5. Authenticating with Facebook, Twitter, and Google
        6. Composing an Express Router
        7. Bringing in the Book Bundle UI
        8. Serving in Production
        9. Wrapping Up
    6. 10. BONUS: Developing Flows with Node-RED
      1. Setting Up Node-RED
      2. Securing Node-RED
      3. Developing a Node-RED Flow
      4. Creating HTTP APIs with Node-RED
      5. Handling Errors in Node-RED Flows
      6. Wrapping Up
    7. A1. Setting Up Angular
    8. A2. Setting Up React

    Product information

    • Title: Node.js 8 the Right Way
    • Author(s): Jim Wilson
    • Release date: January 2018
    • Publisher(s): Pragmatic Bookshelf
    • ISBN: 9781680501957