Home > Store

Sams Teach Yourself Node.js in 24 Hours

Register your product to gain access to bonus material or receive a coupon.

Sams Teach Yourself Node.js in 24 Hours

Best Value Purchase

Book + eBook Bundle

  • Your Price: $43.19
  • List Price: $71.98
  • Includes EPUB, MOBI, and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    MOBI MOBI The eBook format compatible with the Amazon Kindle and Amazon Kindle applications.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

More Purchase Options

Book

  • Your Price: $31.99
  • List Price: $39.99
  • Usually ships in 24 hours.

eBook (Watermarked)

  • Your Price: $25.59
  • List Price: $31.99
  • Includes EPUB, MOBI, and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    MOBI MOBI The eBook format compatible with the Amazon Kindle and Amazon Kindle applications.

    Adobe Reader PDF The popular standard, used most often with the free Adobe® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

Description

  • Copyright 2013
  • Dimensions: 7" x 9-1/8"
  • Pages: 464
  • Edition: 1st
  • Book
  • ISBN-10: 0-672-33595-6
  • ISBN-13: 978-0-672-33595-2

In just 24 sessions of one hour or less, Sams Teach Yourself Node.js in 24 Hours will help you master the Node.js platform and use it to build server-side applications with extraordinary speed and scalability. Using this text’s straightforward, step-by-step approach, you’ll move from basic installation, configuration, and programming all the way through real-time messaging between browser and server, testing and deployment. Every lesson and case-study application builds on what you’ve already learned, giving you a rock-solid foundation for real-world success!

Step-by-step instructions carefully walk you through the most common Node.js development tasks.

Quizzes and Exercises at the end of each chapter help you test your knowledge.

By the Way notes present valuable additional information related to the discussion.

Did You Know? tips offer advice or show you easier ways to perform tasks.

Watch Out! cautions alert you to possible problems and give you advice on how to avoid them.

Learn how to…

·         Create end-to-end applications entirely in JavaScript

·         Master essential Node.js concepts like callbacks and quickly create your first program

·         Create basic sites with the HTTP module and Express web framework

·         Manage data persistence with Node.js and MongoDB

·         Debug and test Node.js applications

·         Deploy Node.js applications to thirdparty services, such as Heroku and Nodester

·         Build powerful real-time solutions, from chat servers to Twitter clients

·         Create JSON APIs using JavaScript on the server

·         Use core components of the Node.js API, including processes, child processes, events, buffers, and streams

·         Create and publish a Node.js module

Extras

Related Article

Taming Networks with JavaScript and Node.js

Companion Site

A link from Sams Teach Yourself Node.js in 24 Hours can be found here: http://nodejsbook.io.

Sample Content

Online Sample Chapter

Using Node.js and Socket.IO with Twitter’s Streaming API

Sample Pages

Download the sample pages (includes Chapter 14 and Index)

Table of Contents

Introduction 1

Who Should Read This Book?     1

Why Should I Learn Node.js?     2

How This Book Is Organized     2

Code Examples    2

Conventions Used in This Book     3

Part I: Getting Started

Hour 1: Introducing Node.js     7

What Is Node.js?    7

What You Can Do with Node.js     8

Installing and Creating Your First Node.js Program     9

Summary     11

Q&A     12

Workshop     12

Exercises     13

Hour 2: npm (Node Package Manager)      15

What Is npm?     15

Installing npm     16

Installing Modules     17

Using Modules     17

How to Find Modules     19

Local and Global Installation     21

How to Find Module Documentation     22

Specifying Dependencies with package.json     23

Summary     25

Q&A     25

Workshop     26

Hour 3: What Node.js Is Used For 27

What Node.js Is Designed to Do     27

Understanding I/O     27

Dealing with Input     29

Networked I/O Is Unpredictable     33

Humans Are Unpredictable     35

Dealing with Unpredictability     37

Summary     38

Q&A     38

Workshop     39

Exercises     39

Hour 4: Callbacks      41

What Is a Callback?     41

The Anatomy of a Callback     46

How Node.js Uses Callbacks     47

Synchronous and Asynchronous Code     50

The Event Loop     53

Summary     54

Q&A     55

Workshop     55

Exercises     56

Part II: Basic Websites with Node.js

Hour 5: HTTP      59

What Is HTTP?      59

HTTP Servers with Node.js     59

HTTP Clients with Node.js     69

Summary     70

Q&A     71

Workshop     71

Exercises     72

Hour 6: Introducing Express 73

What Is Express?      73

Why Use Express?      73

Installing Express     74

Creating a Basic Express Site     74

Exploring Express     76

Introducing Jade     77

Summary     89

Q&A     89

Workshop     90

Exercises     90

Hour 7: More on Express      91

Routing in Web Applications     91

How Routing Works in Express     91

Adding a GET Route     92

Adding a POST Route     94

Using Parameters in Routes     95

Keeping Routes Maintainable     96

View Rendering     97

Using Local Variables     99

Summary     101

Q&A     101

Workshop     101

Exercises     102

Hour 8: Persisting Data      103

What Is Persistent Data?      103

Writing Data to a File     104

Reading Data from a File     105

Reading Environment Variables     106

Using Databases     108

Using MongoDB with Node.js     109

Summary     131

Q&A     131

Workshop     132

Exercises     132

Part III: Debugging, Testing, and Deploying

Hour 9: Debugging Node.js Applications      135

Debugging     135

The STDIO Module     136

The Node.js Debugger     141

Node Inspector     144

A Note on Testing     147

Summary     148

Q&A     148

Workshop     149

Exercises     149

Hour 10: Testing Node.js Applications     151

Why Test?      151

The Assert Module     152

Third-Party Testing Tools     155

Behavior Driven Development     159

Summary     167

Q&A     167

Workshop     168

Exercises     168

Hour 11: Deploying Node.js Applications     169

Ready to Deploy!      169

Hosting in the Cloud     169

Heroku     171

Cloud Foundry     176

Nodester     180

Other PaaS Providers     184

Summary     184

Q&A     184

Workshop     185

Exercises     186

Part IV: Intermediate Sites with Node.js

Hour 12: Introducting Socket.IO      189

Now for Something Completely Different     189

Brief History of the Dynamic Web     189

Socket.IO     191

Basic Socket.IO Example     191

Sending Data from the Server to Clients     194

Broadcasting Data to Clients     199

Bi-Directional Data     204

Summary     209

Q&A     209

Workshop     210

Exercises     210

Hour 13: A Socket.IO Chat Server     213

Express and Socket.IO     213

Adding Nicknames     216

Summary     235

Q&A     235

Workshop     236

Exercises     236

Hour 14: A Streaming Twitter Client      237

Streaming APIs     237

Signing Up for Twitter     238

Using Twitter’s API with Node.js     241

Extracting Meaning from the Data     244

Pushing Data to the Browser     247

Creating a Real-Time Lovehateometer     252

Summary     262

Q&A     263

Workshop     263

Exercises     264

Hour 15: JSON APIs      265

APIs     265

JSON     266

Sending JSON Data with Node.js     268

Creating JSON from JavaScript Objects     269

Consuming JSON Data with Node.js     271

Creating a JSON API with Node.js     275

Summary     285

Q&A     286

Workshop     286

Exercises     287

Part V: Exploring the Node.js API

Hour 16: The Process Module      291

What Processes Are     291

Exiting and Errors in Processes     293

Processes and Signals     293

Sending Signals to Processes     295

Creating Scripts with Node.js     297

Passing Arguments to Scripts     298

Summary     301

Q&A     302

Workshop     302

Exercises     303

Hour 17: The Child Process Module      305

What Is a Child Process?      305

Killing a Child Process     308

Communicating with a Child Process     309

The Cluster Module     311

Summary     314

Q&A     314

Workshop     314

Exercises     315

Hour 18: The Events Module      317

Understanding Events     317

Demonstrating Events Through HTTP     321

Playing Ping-Pong with Events     324

Programming Event Listeners Dynamically     326

Summary     330

Q&A     330

Workshop     331

Exercises     331

Hour 19: The Buffer Module      333

A Primer on Binary Data     333

Binary to Text     334

Binary and Node.js     335

What Are Buffers in Node.js?      338

Writing to Buffers     340

Appending to Buffers     340

Copying Buffers     342

Modifying Strings in Buffers     343

Summary     343

Q&A     343

Workshop     344

Hour 20: The Stream Module      345

A Primer on Streams     345

Readable Streams     347

Writable Streams     352

Piping Streams     353

Streaming MP3s     354

Summary     356

Q&A     356

Workshop     356

Exercises     357

Part VI: Further Node.js Development

Hour 21: CoffeeScript      361

What Is CoffeeScript?      361

Installing and Running CoffeeScript     363

Why Use a Pre-Compiler?     365

Features of CoffeeScript     366

Debugging CoffeeScript     376

Reactions to CoffeeScript     377

Summary     378

Q&A     378

Workshop     379

Exercises     379

Hour 22: Creating Node.js Modules      381

Why Create Modules?      381

Popular Node.js Modules     381

The package.json File     383

Folder Structure     384

Developing and Testing Your Module     385

Adding an Executable     388

Using Object-Oriented or Prototype-Based Programming     390

Sharing Code Via GitHub     391

Using Travis CI     392

Publishing to npm     395

Publicizing Your Module     397

Summary     397

Q&A     397

Workshop     398

Exercises     398

Hour 23: Creating Middleware with Connect      399

What Is Middleware?      399

Middleware in Connect     400

Access Control with Middleware     406

Summary     414

Q&A     414

Workshop     415

Exercises     415

Hour 24: Using Node.js with Backbone.js     417

What Is Backbone.js?     417

How Backbone.js Works     418

A Simple Backbone.js View     425

Creating Records with Backbone.js     429

Summary     432

Q&A     432

Workshop     433

Exercises     433

Index      435

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020