Home Page Icon
Home Page
Table of Contents for
Title
Close
Title
by Azat Mardan
Practical Node.js: Building Real-World Scalable Web Apps
Cover
Title
Copyright
Dedication
Contents at a Glance
Contents
About the Author
About the Technical Reviewer
Acknowledgments
Introduction
Chapter 1: Setting up Node.js and Other Essentials
Installing Node.js and NPM
One-Click Installers
Installing with HomeBrew or MacPorts
Installing from a Tar File
Installing Without sudo
Installing from a Git Repo
Multiversion Setup with Nave
Multiversion Setup with NVM
Alternative Multiversion Systems
Checking the Installation
Node.js Console (REPL)
Launching Node.js Scripts
Node.js Basics and Syntax
Loose Typing
Buffer—Node.js Super Data Type
Object Literal Notation
Functions
Arrays
Prototypal Nature
Conventions
Node.js Globals and Reserved Keywords
__dirname vs. process.cwd
Browser Application Programming Interface Helpers
Node.js Core Modules
Handy Node.js Utilities
Reading to and Writing from the File System in Node.js
Streaming Data in Node.js
Installing Node.js Modules with NPM
Taming Callbacks in Node.js
Hello World Server with HTTP Node.js Module
Debugging Node.js Programs
Core Node.js Debugger
Debugging with Node Inspector
Node.js IDEs and Code Editors
Watching for File Changes
Summary
Chapter 2: Using Express.js 4 to Create Node.js Web Apps
What Is Express.js?
How Express.js Works
Express.js Installation
Express.js Version
Express.js Generator
Local Express.js
Express.js Scaffolding
Express.js Command-Line Interface
Routes in Express.js
Middleware as the Backbone of Express.js
Configuration of an Express.js App
Jade Is Haml for Express.js/Node.js
Conclusion About Scaffolding
The Blog Project Overview
Submitting the Data
Express.js 4 Hello World Example
Setting up Folders
NPM Init and package.json
Dependency Declaration: npm install
The App.js File
Meet Jade: One Template to Rule Them All
Running the Hello World App
Summary
Chapter 3: TDD and BDD for Node.js with Mocha
Installing and Understanding Mocha
Understanding Mocha Hooks
TDD with the Assert
Chai Assert
BDD with Expect.js
Expect.js Syntax
Project: Writing the First BDD Test for Blog
Putting Configs into a Makefile
Summary
Chapter 4: Template Engines: Jade and Handlebars
Jade Syntax and Features
Tags
Variables/Locals
Attributes
Literals
Text
Script and Style Blocks
JavaScript Code
Comments
Conditions (if)
Iterations (each loops)
Filters
Interpolation
Case
Mixins
Include
Extend
Standalone Jade Usage
Handlebars Syntax
Variables
Iteration (each)
Unescaped Output
Conditions (if)
Unless
With
Comments
Custom Helpers
Includes (Partials)
Standalone Handlebars Usage
Jade and Handlebars Usage in Express.js 4
Jade and Express.js
Handlebars and Express.js
Project: Adding Jade Templates to Blog
layout.jade
index.jade
article.jade
login.jade
post.jade
admin.jade
Summary
Chapter 5: Persistence with MongoDB and Mongoskin
Easy and Proper Installation of MongoDB
Easy and Proper Installation of MongoDB
How to Run the Mongo Server
Data Manipulation from the Mongo Console
MongoDB Shell in Detail
Minimalistic Native MongoDB Driver for Node.js Example
Main Mongoskin Methods
Project: Storing Blog Data in MongoDB with Mongoskin
Project: Adding MongoDB Seed Data
Project: Writing Mocha Tests
Project: Adding Persistence
Running the App
Summary
Chapter 6: Using Sessions and OAuth to Authorize and Authenticate Users in Node.js Apps
Authorization with Express.js Middleware
Token-Based Authentication
Session-Based Authentication
Project: Adding E-mail and Password Login to Blog
Session Middleware
Authorization in Blog
Authentication in Blog
Running the App
Node.js OAuth
Twitter OAuth 2.0 Example with Node.js OAuth
Everyauth
Project: Adding Twitter OAuth 1.0 Sign-in to Blog with Everyauth
Adding a Sign-in with a Twitter Link
Configuring the Everyauth Twitter Strategy
Summary
Chapter 7: Boosting Your Node.js Data with the Mongoose ORM Library
Mongoose Installation
Connection Establishment in a Standalone Mongoose Script
Mongoose Schemas
Hooks for Keeping Code Organized
Custom Static and Instance Methods
Mongoose Models
Relationships and Joins with Population
Nested Documents
Virtual Fields
Schema Type Behavior Amendment
Express.js + Mongoose = True MVC
Summary
Chapter 8: Building Node.js REST API Servers with Express.js and Hapi
RESTful API Basics
Project Dependencies
Test Coverage with Mocha and Superagent
REST API Server Implementation with Express and Mongoskin
Refactoring: Hapi RESP API Server
Summary
Chapter 9: Real-Time Apps with WebSocket, Socket.IO, and DerbyJS
What Is WebSocket?
Native WebSocket and Node.js with the ws Module Example
Browser WebSocket Implementation
Node.js Server with ws Module Implementation
Socket.IO and Express.js Example
Collaborative Online Code Editor Example with DerbyJS, Express.js, and MongoDB
Project Dependencies and package.json
Server-side Code
DerbyJS App
DerbyJS View
Editor Tryout
Summary
Chapter 10: Getting Node.js Apps Production Ready
Environment Variables
Express.js in Production
Socket.IO in Production
Error Handling
Node.js Domains for Error Handling
Multithreading with Cluster
Multithreading with Cluster2
Event Logging and Monitoring
Monitoring
REPL in Production
Winston
Papertrail App for Logging
Building Tasks with Grunt
Git for Version Control and Deployments
Installing Git
Generating SSH Keys
Creating a Local Git Repository
Pushing the Local Repository to GitHub
Running Tests in Cloud with TravisCI
TravisCI Configuration
Summary
Chapter 11: Deploying Node.js Apps
Deploying to Heroku
Deploying to Amazon Web Services
Keeping Node.js Apps Alive with forever, Upstart, and init.d
forever
Upstart Scripts
init.d
Serving Static Resources Properly with Nginx
Caching with Varnish
Summary
Chapter 12: Publishing Node.js Modules and Contributing to Open Source
Recommended Folder Structure
Required Patterns
package.json
Publishing to NPM
Locking Versions
Summary
Practical Node.js Conclusion
Further Reading
Errata and Contacts
Index
Search in book...
Toggle Font Controls
Playlists
Add To
Create new playlist
Name your new playlist
Playlist description (optional)
Cancel
Create playlist
Sign In
Email address
Password
Forgot Password?
Create account
Login
or
Continue with Facebook
Continue with Google
Sign Up
Full Name
Email address
Confirm Email Address
Password
Login
Create account
or
Continue with Facebook
Continue with Google
Prev
Previous Chapter
Cover
Next
Next Chapter
Copyright
Practical Node.js
Building Real-World Scalable Web Apps
Azat Mardan
Add Highlight
No Comment
..................Content has been hidden....................
You can't read the all page of ebook, please click
here
login for view all page.
Day Mode
Cloud Mode
Night Mode
Reset