Node Cookbook
eBook - ePub

Node Cookbook

  1. 342 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Node Cookbook

Book details
Book preview
Table of contents
Citations

About This Book

In Detail

The principles of asynchronous event-driven programming are perfect for today's web, where efficient real-time applications and scalability are at the forefront. Server-side JavaScript has been here since the 90's but Node got it right. With a thriving community and interest from Internet giants, it could be the PHP of tomorrow.

"Node Cookbook" shows you how to transfer your JavaScript skills to server side programming. With simple examples and supporting code, "Node Cookbook" talks you through various server side scenarios often saving you time, effort, and trouble by demonstrating best practices and showing you how to avoid security faux pas.

Beginning with making your own web server, the practical recipes in this cookbook are designed to smoothly progress you to making full web applications, command line applications, and Node modules. Node Cookbook takes you through interfacing with various database backends such as MySQL, MongoDB and Redis, working with web sockets, and interfacing with network protocols, such as SMTP. Additionally, there are recipes on correctly performing heavy computations, security implementations, writing, your own Node modules and different ways to take your apps live.

Approach

As part of Packt's cookbook series, this book is packed with practical recipes that will get you working efficiently with Node from the start. Each chapter focuses on a different aspect of working with Node.

Who this book is for

If you have some knowledge of JavaScript and want to build fast, efficient, scalable client-server solutions, then Node Cookbook is for you. Experienced users of Node will improve their skills although even if you have not worked with Node before, these practical recipes will make it easy to get started.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access Node Cookbook by David Mark Clements in PDF and/or ePUB format, as well as other popular books in Computer Science & Application Development. We have over one million books available in our catalogue for you to explore.

Information

Year
2012
ISBN
9781849517188
Edition
1

Node Cookbook


Table of Contents

Node Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Making a Web Server
Introduction
Setting up a router
Getting ready
How to do it...
How it works...
There's more...
Simple multilevel routing
Parsing the querystring
Routing modules
See also
Serving static files
Getting ready
How to do it...
How it works...
There's more...
The favicon gotcha
See also
Caching content in memory for immediate delivery
Getting ready
How to do it...
How it works...
There's more...
Reflecting content changes
See also
Optimizing performance with streaming
Getting ready
How to do it...
How it works...
There's more...
Protecting against process memory overruns
See also
Securing against filesystem hacking exploits
Getting ready
How to do it...
How it works...
There's more...
Whitelisting
Node-static
See also
2. Exploring the HTTP Object
Introduction
Processing POST data
Getting ready
How to do it...
How it works...
There's more...
Accessing POST data with connect.bodyParser
See also
Handling file uploads
Getting ready
How to do it...
How it works...
There's more...
Using formidable to accept all POST data
Preserving filenames with formidable
Uploading via PUT
See also
Using Node as an HTTP client
Getting ready
How to do it...
How it works...
There's more...
Sending POST requests
Multipart file upload as a client
See also
Implementing download throttling
Getting ready
How to do it...
How it works...
Enabling resumes from broken downloads
See also
3. Working with Data Serialization
Introduction
Converting an object to JSON and back again
Getting ready
How to do it...
How it works...
There's more...
Constructing JSONP responses
Security and JSONP
See also
Converting an object to XML and back again
Getting ready
How to do it...
How it works...
There's more...
Objects containing arrays and functions
Generating XML attributes
Text values alongside attribute declarations
See also
Browser-server transmission via AJAX
Getting ready
How to do it...
How it works...
There's more...
Sending serialized data from client to server
See also
Working with real data: fetching trending tweets
Getting ready
How to do it...
How it works...
Twitter API and the User-Agent header
There's more...
Cross referencing Google Hot Trends with Twitter tweets
See also
4. Interfacing with Databases
Introduction
Writing to a CSV file
Getting ready
How to do it...
How it works...
There's more...
Customizing the CSV elements
Reading a CSV file
Manipulating CSV as a stream
See also
Connecting and sending SQL to a MySQL server
Getting ready
How to do it...
How it works...
There's more...
Using and cleaning user input
Receiving results from the MySQL server
See also
Storing and retrieving data with MongoDB
Getting ready
How to do it...
How it works...
There's more...
Indexing and aggregation
Updating modifiers, sort, and limit
See also
Storing and retrieving data with Mongoskin
Getting ready
How to do it...
How it works...
There's more...
Collection binding
See also
Storing data to CouchDB with Cradle
Getting ready
How to do it...
How it works...
There's more...
Scaling CouchDB with BigCouch
See also
Retrieving data from CouchDB with Cradle
Getting ready
How to do it...
How it works...
There's more...
Creating an admin user
Locking all modifying operations to an admin user
Exposing the CouchDB HTTP interface to remote connections
See also
Accessing CouchDB changes stream with Cradle
Getting ready
How to do it...
How it works...
See also
Storing and retrieving data with Redis
Getting ready
How to do it...
How it works...
There's more...
Speeding up node Redis module
Overcoming network latency by pipelining commands
See also
Implementing PubSub with Redis
Getting ready
How to do it...
How it works...
There's more...
Redis authentication
Securing Redis from external connections
See also
5. Transcending AJAX: Using WebSockets
Introduction
Creating a WebSocket server
Getting ready
How to do it...
How it works...
There's more...
Supporting older Firefox browsers
Creating a node-based WebSocket client
See also
Seamless fallbacking with socket.io
Getting ready
How to do it...
How it works...
There's more...
Custom events
Namespaces
See also
Callbacks over socket.io transport
Getting ready
How to do it...
How it works...
There's more...
Shared functions with Nowjs
See also
Creating a real-time widget
Getting ready
How to do it...
How it works...
There's more...
Preparing for scalability
WebSockets as a development tool
See also
6. Accelerating Development with Express
Introduction
Generating Express scaffolding
Getting ready
How to do it...
How it works...
There's more...
Picking apart app.js
Looking into routes/index.js
See also
Defining and applying environments
Getting ready
How to do it...
How it works...
There's more...
Setting other environments
Changing NODE_ENV permanently
See also
Dynamic routing
Getting ready
How to do it...
How it works...
There's more...
Route validation
Optional routes
Asterisks wildcards
See also
Templating in Express
Getting ready
How to do it...
How it works...
There's more...
Using other template eng...

Table of contents

  1. Node Cookbook