Smashing Node.js: JavaScript Everywhere

( 2 )

Overview

Learn to make more efficient apps, with just one language!

Smashing Node.js: JavaScript Everywhere equips you with the necessary tools to understand Node.js and its uses in developing efficient web apps. With more traditional web servers becoming obsolete, having knowledge on servers that achieve high scalability and optimal resource consumption using Node.js is the key to your app development success. Teaching you the essentials to making event-driven server-side apps, this ...

See more details below
Paperback
$31.22
BN.com price
(Save 30%)$44.99 List Price

Pick Up In Store

Reserve and pick up in 60 minutes at your local store

Other sellers (Paperback)
  • All (14) from $14.60   
  • New (10) from $24.10   
  • Used (4) from $14.60   
Smashing Node.js: JavaScript Everywhere

Available on NOOK devices and apps  
  • NOOK Devices
  • NOOK HD/HD+ Tablet
  • NOOK
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac
  • NOOK Study
  • NOOK for Web

Want a NOOK? Explore Now

NOOK Book (eBook)
$25.99
BN.com price
(Save 42%)$44.99 List Price

Overview

Learn to make more efficient apps, with just one language!

Smashing Node.js: JavaScript Everywhere equips you with the necessary tools to understand Node.js and its uses in developing efficient web apps. With more traditional web servers becoming obsolete, having knowledge on servers that achieve high scalability and optimal resource consumption using Node.js is the key to your app development success. Teaching you the essentials to making event-driven server-side apps, this book demonstrates how you can use less space and take less time for communication between web client and server.

  • Contains numerous hands-on examples
  • Explains implementation of real-time apps including Socket.IO and HTML5, and WebSockets
  • Addresses practical Node.js advantages from specific design choices
  • Demonstrates why knowledge and use of JavaScript is beneficial
  • Includes an interactive online component with sample chapters
  • Explains components of stand out apps including brevity and benchmarks

Looking to enhance your abilities even further? Smashing Node.js: JavaScript Everywhere makes developing server-side apps accessible with its focus on JavaScript, open source, and easy-to-use language.

Read More Show Less

Product Details

  • ISBN-13: 9781119962595
  • Publisher: Wiley, John & Sons, Incorporated
  • Publication date: 9/11/2012
  • Series: Smashing Magazine Book Series , #35
  • Edition number: 2
  • Pages: 320
  • Sales rank: 422,513
  • Product dimensions: 8.90 (w) x 7.30 (h) x 0.70 (d)

Meet the Author

Guillermo Rauch is CTO and co-founder of San Francisco-based education startup LearnBoost. He is the inventor of several renowned Node.js projects, and he has been a speaker at JSConf as well as Nod.js workshops.

Read More Show Less

Table of Contents

PART I: GETTING STARTED: SETUP AND CONCEPTS 5

Chapter 1: The Setup 7

Installing on Windows 8

Installing on OS X 8

Installing on Linux 8

Compiling 9

Ensuring that it works 9

The Node REPL 9

Executing a file 10

NPM 10

Installing modules 11

Defining your own module 12

Installing binary utilities 13

Exploring the NPM registry 14

Summary 14

Chapter 2: JavaScript: An Overview 15

Introduction 15

Basic JavaScript 16

Types 16

Type hiccups 16

Functions 18

this, Function#call, and Function#apply 18

Functionarity 19

Closures 19

Classes 20

Inheritance 20

try {} catch {} 21

v8 JavaScript 22

Object#keys 22

Array#isArray 23

Array methods 23

String methods 24

JSON 24

Function#bind 24

Function#name 24

_proto_ (inheritance) 25

Accessors 25

Summary 26

Chapter 3: Blocking and Non-blocking IO 27

With great power comes great responsibility 28

Blocking-ness 29

A single-threaded world 31

Error handling 33

Stack traces 35

Summary 37

Chapter 4: Node JavaScript 39

The global object 40

Useful globals 40

The module system 41

Absolute and relative modules 41

Exposing APIs 44

Events 45

Buffers 47

Summary 48

PART II: ESSENTIAL NODE APIS 49

Chapter 5: CLI and FS APIs: Your First Application 51

Requirements 52

Writing your first program 52

Creating the module 53

Sync or async? 54

Understanding streams 55

Input and ouput 57

Refactoring 59

Interacting with the fs 61

Exploring the CLI 63

Argv 63

Working directory 64

Environmental variables 65

Exiting 65

Signals 65

ANSI escape codes 66

Exploring the fs module 66

Streams 67

Watch 67

Summary 68

Chapter 6: TCP 69

What are the characteristics of TCP? 70

Connection-oriented communication and same-order delivery 70

Byte orientation 70

Reliability 71

Flow control 71

Congestion control 71

Telnet 71

A TCP chat program 74

Creating the module 74

Understanding the net.server API 74

Receiving connections 76

The data event 77

State and keeping track of connections 79

Wrap up 81

An IRC Client program 83

Creating the module 83

Understanding the net#Stream API 84

Implementing part of the IRC protocol 84

Testing with a real-world IRC server 85

Summary 85

Chapter 7: HTTP 87

The structure of HTTP 88

Headers 89

Connections 93

A simple web server 94

Creating the module 95

Printing out the form 95

Methods and URLs 97

Data 99

Putting the pieces together 102

Bullet-proofing 103

A Twitter web client 104

Creating the module 104

Making a simple HTTP request 104

Sending a body of data 106

Getting tweets 107

A superagent to the rescue 110

Reloading HTTP servers with up 111

Summary 112

PART III: WEB DEVELOPMENT 113

Chapter 8: Connect 115

A simple website with HTTP 116

A simple website with Connect 119

Middleware 121

Writing reusable middleware 122

Static middleware 127

Query 128

Logger 129

Body parser 131

Cookies 134

Session 134

REDIS sessions 140

methodOverride 141

basicAuth 141

Summary 144

Chapter 9: Express 145

A simple express app 146

Creating the module 146

HTML 146

Setup 147

Defining routes 148

Search 150

Run 152

Settings 153

Template engines 154

Error handling 155

Convenience methods 155

Routes 157

Middleware 159

Organization strategies 160

Summary 162

Chapter 10: WebSocket 163

AJAX 164

HTML5 WebSocket 166

An Echo Example 167

Setting it up 167

Setting up the server 168

Setting up the client 169

Running the server 170

Mouse cursors 171

Setting up the example 171

Setting up the server 172

Setting up the client 174

Running the server 176

The Challenges Ahead 177

Close doesn’t mean disconnect 177

JSON 177

Reconnections 177

Broadcasting 177

WebSockets are HTML5: Older browsers don’t support them 177

The solution 178

Summary 178

Chapter 11: Socket.IO 179

Transports 180

Disconnected versus closed 180

Events 180

Namespaces 181

A chat program 182

Setting up the program 182

Setting up the server 182

Setting up the client 183

Events and Broadcasting 185

Ensuring reception 190

A DJ-by-turns application 191

Extending the chat 191

Integrating with the Grooveshark API 193

Playing 196

Summary 201

PART IV: DATABASES 203

Chapter 12: MongoDB 205

Installation 207

Accessing MongoDB: A user authentication example 208

Setting up the application 208

Creating the Express app 208

Connecting to MongoDB 212

Creating documents 214

Finding documents 215

Authentication middleware 217

Validation 218

Atomicity 219

Safe mode 219

Introducing Mongoose 220

Defining a model 220

Defining nested keys 222

Defining embedded documents 222

Setting up indexes 222

Middleware 223

Inspecting the state of the model 223

Querying 224

Extending queries 224

Sorting 224

Making Selections 224

Limiting 225

Skipping 225

Populating keys automatically 225

Casting 225

A mongoose example 226

Setting up the application 226

Refactoring 226

Setting up models 227

Summary 229

Chapter 13: MySQL 231

node-mysql 232

Setting it up 232

The Express app 232

Connecting to MySQL 234

Initializing the script 234

Creating data 238

Fetching data 242

sequelize 244

Setting up sequelize 245

Setting up the Express app 245

Connecting sequelize 248

Defining models and synchronizing 249

Creating data 250

Retrieving data 253

Removing data 254

Wrapping up 256

Summary 257

Chapter 14: Redis 259

Installing Redis 261

The Redis query language 261

Data types 262

Strings 263

Hashes 263

Lists 265

Sets 265

Sorted sets 266

Redis and Node 266

Implementing a social graph with node-redis 267

Summary 276

PART V: TESTING 277

Chapter 15: Code Sharing 279

What can be shared? 280

Writing compatible JavaScript 280

Exposing modules 280

Shimming ECMA APIs 282

Shimming Node APIs 283

Shimming browser APIs 284

Cross-browser inheritance 284

Putting it all together: browserbuild 285

A basic example 286

Summary 288

Chapter 16: Testing 289

Simple testing 290

The test subject 290

The test strategy 290

The test program 291

Expect.JS 292

API overview 292

Mocha 294

Testing asynchronous code 295

BDD style 297

TDD style 298

Exports style 298

Taking Mocha to the browser 299

Summary 300

Read More Show Less

Customer Reviews

Average Rating 5
( 2 )
Rating Distribution

5 Star

(2)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 2 Customer Reviews
  • Anonymous

    Posted March 30, 2013

    Helo

    Jello man! <br >

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted October 11, 2012

    Great introduction to node.js

    Guilhermo does a great job showing the principles behind the development for node.js, covering the main modules by writing usable apps. Simply, a book that any webdeveloper should have in it's library.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing all of 2 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)