ffirs.indd iffirs.indd i 22/09/12 10:16 AM22/09/12 10:16 AM
PROFESSIONAL NODE.JS®
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxvii
PART I INTRODUCTION AND SETUP
CHAPTER 1 Installing Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
CHAPTER 2 Introducing Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15
PART II NODE CORE API BASICS
CHAPTER 3 Loading Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
CHAPTER 4 Using Bu ers to Manipulate, Encode, and Decode Binary Data . . . . . . 29
CHAPTER 5 Using the Event Emitter Pattern to Simplify Event Binding . . . . . . . . . . 35
CHAPTER 6 Scheduling the Execution of Functions Using Timers . . . . . . . . . . . . . . . 45
PART III FILES, PROCESSES, STREAMS, AND NETWORKING
CHAPTER 7 Querying, Reading from, and Writing to Files . . . . . . . . . . . . . . . . . . . . . . 53
CHAPTER 8 Creating and Controlling External Processes . . . . . . . . . . . . . . . . . . . . . . 63
CHAPTER 9 Reading and Writing Streams of Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
CHAPTER 10 Building TCP Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
CHAPTER 11 Building HTTP Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
CHAPTER 12 Building a TCP Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
CHAPTER 13 Making HTTP Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
CHAPTER 14 Using Datagrams (UDP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
CHAPTER 15 Securing Your TCP Server with TLS/SSL . . . . . . . . . . . . . . . . . . . . . . . . . 139
CHAPTER 16 Securing Your HTTP Server with HTTPS . . . . . . . . . . . . . . . . . . . . . . . . . 149
PART IV BUILDING AND DEBUGGING MODULES AND APPLICATIONS
CHAPTER 17 Testing Modules and Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
CHAPTER 18 Debugging Modules and Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
CHAPTER 19 Controlling the Callback Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177
Continues
ffirs.indd iffirs.indd i 22/09/12 10:16 AM22/09/12 10:16 AM
Do w n lo a d f r o m W o w! e Bo o k < w w w.w o web o ok. c om>
PART V BUILDING WEB APPLICATIONS
CHAPTER 20 Building and Using HTTP Middleware . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
CHAPTER 21 Making a Web Application Using Express.js . . . . . . . . . . . . . . . . . . . . . . 217
CHAPTER 22 Making Universal Real-Time Web Applications Using Socket.IO . . . . 241
PART VI CONNECTING TO DATABASES
CHAPTER 23 Connecting to MySQL Using node-mysql . . . . . . . . . . . . . . . . . . . . . . . . 267
CHAPTER 24 Connecting to CouchDB Using Nano . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
CHAPTER 25 Connecting to MongoDB Using Mongoose . . . . . . . . . . . . . . . . . . . . . . . 311
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .351
ffirs.indd iiffirs.indd ii 22/09/12 10:16 AM22/09/12 10:16 AM
PROFESSIONAL
Node.js
®
ffirs.indd iiiffirs.indd iii 22/09/12 10:16 AM22/09/12 10:16 AM