Mastering Node.js


Mastering Node.js
eBook: $29.99
Formats: PDF, PacktLib, ePub and Mobi formats
$25.49
save 15%!
Print + free eBook + free PacktLib access to the book: $79.98    Print cover: $49.99
$49.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Master the latest techniques for building real-time, big data applications, integrating Facebook, Twitter, and other network services
  • Tame asynchronous programming, the event loop, and parallel data processing
  • Use the Express and Path frameworks to speed up development and deliver scalable, higher quality software more quickly

Book Details

Language : English
Paperback : 346 pages [ 235mm x 191mm ]
Release Date : November 2013
ISBN : 1782166327
ISBN 13 : 9781782166320
Author(s) : Sandro Pasquali
Topics and Technologies : All Books, Open Source, Web Development


Table of Contents

Preface
Chapter 1: Understanding the Node Environment
Chapter 2: Understanding Asynchronous Event-Driven Programming
Chapter 3: Streaming Data Across Nodes and Clients
Chapter 4: Using Node to Access the Filesystem
Chapter 5: Managing Many Simultaneous Client Connections
Chapter 6: Creating Real-time Applications
Chapter 7: Utilizing Multiple Processes
Chapter 8: Scaling Your Application
Chapter 9: Testing Your Application
Appendix A: Organizing Your Work
Appendix B: Introducing the Path Framework
Appendix C: Creating Your Own C++ Add-ons
Index
  • Chapter 2: Understanding Asynchronous Event-Driven Programming
    • Broadcasting events
      • Collaboration
      • Queueing
    • Listening for events
      • Signals
      • Forks
      • File events
      • Deferred execution
        • process.nextTick
    • Timers
      • setTimeout
      • setInterval
      • unref and ref
    • Understanding the event loop
      • Four sources of truth
    • Callbacks and errors
      • Conventions
      • Know your errors
      • Building pyramids
      • Considerations
    • Listening for file changes
    • Summary
  • Chapter 3: Streaming Data Across Nodes and Clients
    • Exploring streams
      • Implementing readable streams
        • Pushing and pulling
      • Writable streams
      • Duplex streams
      • Transforming streams
      • Using PassThrough streams
    • Creating an HTTP server
      • Making HTTP requests
      • Proxying and tunneling
    • HTTPS, TLS(SSL), and securing your server
      • Creating a self-signed certificate for development
      • Installing a real SSL certificate
    • The request object
      • The URL module
      • The Querystring module
    • Working with headers
      • Using cookies
      • Understanding content types
      • Handling favicon requests
    • Handling POST data
    • Creating and streaming images with Node
      • Creating, caching, and sending a PNG representation
    • Summary
  • Chapter 4: Using Node to Access the Filesystem
    • Directories, and iterating over files and folders
      • Types of files
      • File paths
      • File attributes
      • Opening and closing files
        • fs.open(path, flags, [mode], callback)
        • fs.close(fd, callback)
      • File operations
        • fs.rename(oldName, newName, callback)
        • fs.truncate(path, len, callback)
        • fs.ftruncate(fd, len, callback)
        • fs.chown(path, uid, gid, callback)
        • fs.fchown(fd, uid, gid, callback)
        • fs.lchown(path, uid, gid, callback)
        • fs.chmod(path, mode, callback)
        • fs.fchmod(fd, mode, callback)
        • fs.lchmod(path, mode, callback)
        • fs.link(srcPath, dstPath, callback)
        • fs.symlink(srcPath, dstPath, [type], callback)
        • fs.readlink(path, callback)
        • fs.realpath(path, [cache], callback)
        • fs.unlink(path, callback)
        • fs.rmdir(path, callback)
        • fs.mkdir(path, [mode], callback)
        • fs.exists(path, callback)
        • fs.fsync(fd, callback)
      • Synchronicity
      • Moving through directories
    • Reading from a file
      • Reading byte by byte
        • fs.read(fd, buffer, offset, length, position, callback)
      • Fetching an entire file at once
        • fs.readFile(path, [options], callback)
      • Creating a readable stream
        • fs.createReadStream(path, [options])
      • Reading a file line by line
        • The Readline module
    • Writing to a file
      • Writing byte by byte
        • fs.write(fd, buffer, offset, length, position, callback)
      • Writing large chunks of data
        • fs.writeFile(path, data, [options], callback)
        • fs.appendFile(path, data, [options], callback)
      • Creating a writable stream
        • fs.createWriteStream(path, [options])
      • Caveats
    • Serving static files
      • Redirecting requests
        • Location
      • Implementing resource caching
    • Handling file uploads
      • Putting it all together
    • Summary
  • Chapter 5: Managing Many Simultaneous Client Connections
    • Understanding concurrency
      • Concurrency is not parallelism
    • Routing requests
      • Understanding routes
      • Using Express to route requests
    • Using Redis for tracking client state
      • Storing user data
    • Handling sessions
      • Cookies and client state
      • A simple poll
      • Centralizing states
    • Authenticating connections
      • Basic authentication
      • Handshaking
    • Summary
    • Further reading
  • Chapter 6: Creating Real-time Applications
    • Introducing AJAX
      • Responding to calls
      • Creating a stock ticker
    • Bidirectional communication with Socket.IO
      • Using the WebSocket API
      • Socket.IO
      • Drawing collaboratively
    • Listening for Server Sent Events
      • Using the EventSource API
      • The EventSource stream protocol
      • Asking questions and getting answers
    • Building a collaborative document editing application
    • Summary
  • Chapter 7: Utilizing Multiple Processes
    • Node's single-threaded model
      • The benefits of single-threaded programming
      • Multithreading is already native and transparent
    • Creating child processes
      • Spawning processes
      • Forking processes
      • Buffering process output
    • Communicating with your child
      • Sending messages to children
    • Parsing a file using multiple processes
      • Using the cluster module
      • Cluster events
      • Worker object properties
      • Worker events
    • Real-time activity updates of multiple worker results
    • Summary
  • Chapter 8: Scaling Your Application
    • When to scale?
      • Network latency
      • Hot CPUs
      • Socket usage
      • Many file descriptors
      • Data creep
      • Tools for monitoring servers
    • Running multiple Node servers
      • Forward and reverse proxies
      • Nginx as a proxy
      • Using HTTP Proxy
    • Message queues – RabbitMQ
      • Types of exchanges
    • Using Node's UDP module
      • UDP multicasting with Node
    • Using Amazon Web Services in your application
      • Authenticating
      • Errors
      • Using S3 to store files
        • Working with buckets
        • Working with objects
        • Using AWS with a Node server
      • Getting and setting data with DynamoDB
        • Searching the database
      • Sending mail via SES
    • Authenticating with Facebook Connect
    • Summary
  • Chapter 9: Testing Your Application
    • Why testing is important
      • Unit tests
      • Functional tests
      • Integration tests
    • Native Node testing and debugging tools
      • Writing to the console
        • Formatting console output
      • The Node debugger
      • The assert module
      • Sandboxing
        • Distinguishing between local scope and execution context
        • Using compiled contexts
      • Errors and exceptions
      • The domain module
    • Headless website testing with ZombieJS and Mocha
      • Mocha
      • Headless web testing
    • Using Grunt, Mocha, and PhantomJS to test and deploy projects
      • Working with Grunt
    • Summary
  • Appendix A: Organizing Your Work
    • Loading and using modules
      • Understanding the module object
      • Resolving module paths
    • Using npm
      • Initializing a package file
      • Using scripts
      • Declaring dependencies
      • Publishing packages
      • Globally installing packages and binaries
      • Sharing repositories

Sandro Pasquali

Sandro Pasquali began writing games on a Commodore PET in grade school, and hasn't looked back. A polyglot programmer, who started with BASIC and assembly, his journey through C, Perl, and PHP led to JavaScript and the browser in 1995. He was immediately hooked on a vision of browsers as the software delivery mechanism of the future. By 1997 he had formed Simple.com, a technology company selling the world's first JavaScript-based application development framework, patenting several technologies and techniques that have proven prescient. Node represents for him only the natural next step in an inevitable march towards the day when all software implementations, and software users, are joined within a collaborative information network. He has led the design of enterprise-grade applications for some of the largest companies in the world, including Nintendo, Major League Baseball, Bang and Olufsen, LimeWire, and others. He has displayed interactive media exhibits during the Venice Biennial, won design awards, built knowledge management tools for research institutes and schools, and has started and run several startups. Always seeking new ways to blend design excellence and technical innovation, he has made significant contributions across all levels of software architecture, from data management and storage tools to innovative user interfaces and frameworks. He now works to mentor a new generation of developers also bitten by the collaborative software bug, especially the rabid ones.
Sorry, we don't have any reviews for this title yet.

Code Downloads

Download the code and support files for this book.


Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


Errata

- 2 submitted: last submission 17 Feb 2014

Errata type: Typo | Preface

 

In Preface, 2nd paragraph, 1st sentence is: "Even though our expectations for software have changed, the tools available to us as
software developers developers have not changed much
."

The word developer appears twice.

It should be: "Even though our expectations for software have changed, the tools available to us as
software developers have not changed much
."

Errata type: Techincal | Page number: 132

 

The link above the third paragraph is: http://www.express.com

It should be: http://expressjs.com/

 

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

Mastering Node.js +    Alfresco 3 Cookbook =
50% Off
the second eBook
Price for both: $45.60

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Discover how Node uses Google’s V8 engine to create high-speed JavaScript on the server
  • Use events to create non-blocking systems with high throughput
  • Create secure servers across all major network protocols
  • Manage thousands of concurrent clients without slowing down
  • Handle data, files, and protocol streams with ease
  • Leverage Node’s module system to design sane applications that are easy to extend
  • Optimize and debug server-side JavaScript for increased performance
  • Learn scaling techniques and parallelize operations across multiple cores

In Detail

Node.js is a modern development stack focused on providing an easy way to build scalable network software. Backed by a growing number of large companies and a rapidly increasing developer base, Node is revolutionizing the way that software is being built today. Powered by Google’s V8 engine and built out of C++ modules, this is a JavaScript environment for the enterprise.

Mastering Node.js will take the reader deep into this exciting development environment. Beginning with a comprehensive breakdown of its innovative non-blocking evented design, Node’s structure is explained in detail, laying out how its blazingly fast I/O performance simplifies the creation of fast servers, scalable architectures, and responsive web applications.

Mastering Node.js takes you through a concise yet thorough tour of Node's innovative evented non-blocking design, showing you how to build professional applications with the help of detailed examples.

Learn how to integrate your applications with Facebook and Twitter, Amazon and Google, creating social apps and programs reaching thousands of collaborators on the cloud. See how the Express and Path frameworks make the creation of professional web applications painless. Set up one, two, or an entire server cluster with just a few lines of code, ready to scale as soon as you’re ready to launch. Move data seamlessly between databases and file systems, between clients, and across network protocols, using a beautifully designed, consistent, and predictable set of tools.

Mastering Node.js contains all of the examples and explanations you’ll need to build applications in a short amount of time and at a low cost, running on a scale and speed that would have been nearly impossible just a few years ago.

Approach

Packed with practical examples and explanations, Mastering Node.js contains everything you need to take your applications to the next level.

Who this book is for

If you’ve ever built a web page and would like to build network software using the language and style you already know, Node will make that process simple, and even fun. If you understand what a server is, what a client is, and how to write JavaScript, you are already halfway to mastering Node.js!

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software