PacktLib: Node Cookbook

Node Cookbook

Credits

About the Author

About the Reviewers

www.PacktPub.com

Preface

Making a Web Server

Introduction

Setting up a router

Serving static files

Caching content in memory for immediate delivery

Optimizing performance with streaming

Securing against filesystem hacking exploits

Exploring the HTTP Object

Introduction

Processing POST data

Handling file uploads

Using Node as an HTTP client

Implementing download throttling

Working with Data Serialization

Introduction

Converting an object to JSON and back again

Converting an object to XML and back again

Browser-server transmission via AJAX

Working with real data: fetching trending tweets

Interfacing with Databases

Introduction

Writing to a CSV file

Connecting and sending SQL to a MySQL server

Storing and retrieving data with MongoDB

Storing and retrieving data with Mongoskin

Storing data to CouchDB with Cradle

Retrieving data from CouchDB with Cradle

Accessing CouchDB changes stream with Cradle

Storing and retrieving data with Redis

Implementing PubSub with Redis

Transcending AJAX: Using WebSockets

Introduction

Creating a WebSocket server

Seamless fallbacking with socket.io

Callbacks over socket.io transport

Creating a real-time widget

Accelerating Development with Express

Introduction

Generating Express scaffolding

Defining and applying environments

Dynamic routing

Templating in Express

CSS engines with Express

Initializing and using a session

Making an Express web app

Implementing Security, Encryption, and Authentication

Introduction

Implementing Basic Authentication

Cryptographic password hashing

Implementing Digest Authentication

Setting up an HTTPS web server

Preventing cross-site request forgery

Integrating Network Paradigms

Introduction

Sending email

Sending SMS

Communicating with TCP

Creating an SMTP server

Implementing a virtual hosting paradigm

Writing Your Own Node Modules

Introduction

Creating a test-driven module API

Writing a functional module mock-up

Refactoring from functional to prototypical

Extending the module's API

Deploying a module to npm

Taking It Live

Introduction

Deploying to a server environment

Automatic crash recovery

Continuous deployment

Hosting with a Platform as a Service provider