PacktLib: Node Web Development - Second Edition

Node Web Development Second Edition

Credits

About the Author

Acknowledgement

About the Reviewers

www.PacktPub.com

Preface

About Node

The capabilities of Node

Why should you use Node?

What's in a name – Node, Node.js, or Node.JS?

Summary

Setting up Node

System requirements

Installing Node using package managers

Installing the StrongLoop Node distribution

Installing from source on POSIX-like systems

Installing developer tools on Mac OS X

Run a few commands; testing the commands

npm – the Node package manager

Starting Node servers at system startup

Summary

Node Modules

Defining a module

Node package manager

Summary

HTTP Servers and Clients – A Web Application's First Steps

Sending and receiving events with EventEmitters

HTTP server applications

HTTP Sniffer – listening to the HTTP conversation

Web application frameworks

Getting started with Express

Calculating the Fibonacci sequence with Express

Making HTTP Client requests

Calling a REST backend service from an Express application

Summary

Implementing a Simple Express Application

Express and the MVC paradigm

Creating the Notes application code

Changing the look of an Express application

Scaling up and running multiple instances

Summary

Data Storage and Retrieval

Asynchronizing the Notes application

Storing notes in files

Storing notes with the LevelUP data store

Storing notes in SQL – SQLite3

Storing notes the ORM way with the Sequelize module

Storing notes in MongoDB with Mongoose

Summary

Multiuser Authorization, Deployment, Scaling, and Hosting

User authentication

Deploying Notes on Debian

Scaling to use all cores on multi-core servers

Deploying Notes on cloud hosting (AppFog)

Summary

Dynamic Interaction between the Client and Server Application

Adding real-time web features to Notes

Introducing Socket.IO

Initializing Socket.IO with Express

Events between the Notes server and client code

Running the Notes application with Socket.IO

Sending messages between users

Summary

Unit Testing

Testing asynchronous code

Assert – the simplest testing methodology

Testing a model

Testing router functions

Making it easy to run the tests

Summary

Index