Practical Node.js: Building Real-World Scalable Web Apps

Practical Node.js: Building Real-World Scalable Web Apps

Azat Mardan

Language: English

Pages: 300

ISBN: 1430265957

Format: PDF / Kindle (mobi) / ePub

Practical Node.js: Building Real-World Scalable Web Apps

Azat Mardan

Language: English

Pages: 300

ISBN: 1430265957

Format: PDF / Kindle (mobi) / ePub


Practical Node.js is your step-by-step guide to learning how to build a wide range of scalable real-world web applications using a professional development toolkit. Node.js is an innovative and highly efficient platform for creating web services. But Node.js doesn't live in a vacuum! In a modern web development, many different components need to be put together — routing, database driver, ORM, session management, OAuth, HTML template engine, CSS compiler and many more.

If you already know the basics of Node.js, now is the time to discover how to bring it to production level by leveraging its vast ecosystem of packages. As a web developer, you'll work with a varied collection of standards and frameworks - Practical Node.js shows you how all those pieces fit together.

Practical Node.js takes you from installing all the necessary modules to writing full-stack web applications by harnessing the power of the Express.js and Hapi frameworks, the MongoDB database with Mongoskin and Mongoose, Jade and Handlebars template engines, Stylus and LESS CSS languages, OAuth and Everyauth libraries, and the Socket.IO and Derby libraries, and everything in between. The book also covers how to deploy to Heroku and AWS, daemonize apps, and write REST APIs. You'll build full-stack real-world Node.js apps from scratch, and also discover how to write your own Node.js modules and publish them on NPM. You already know what Node.js is; now learn what you can do with it and how far you can take it!

Structured Parallel Programming: Patterns for Efficient Computation

Start Here! Learn the Kinect API

Constructing Correct Software (Formal Approaches to Computing and Information Technology)

An Introduction to Programming Using Alice 2.2

Programming F# 3.0

iOS 4 Programming Cookbook: Solutions & Examples for iPhone, iPad, and iPod touch Apps

 

 

 

 

 

 

 

 

 

 

 

(REST) API server, i.e., we have only two end points and they are also called routes. In this application, we use only core Node.js modules for server functions. A single “userland”/external native MongoDB driver module is used for persistence. This example is taken from beginner-friendly Rapid Prototyping with JS (http://rpjs.co/): Agile JavaScript Development by Azat Mardan [2013]:   var http = require('http'); var util = require('util'); var querystring = require('querystring'); var mongo =

handlebars-example.html file that uses custom_title helper has this content that calls the helper and outputs some other properties:  

{{custom_title title}}

{{body}}

  To produce this HTML when we run $ node handlebars-example.js 'email body', use the following:  

respectively, $ node mongo-native, while running the mongod service, the scripts should output something similar to the results in Figure 5-4. There are three documents. The first is without the property text; the second and third documents include it. Figure 5-4.  Running a simple MongoDB script with a native driver The full documentation of this library is available at http://mongodb.github.com/node-mongodb-native/ api-generated/db.html and on the MongoDB web site

Node.js script from a file, simply run $ node filename—for example, $ node program.js. If all we need is a quick set of statements, there’s a -e option that allows us to run inline JavaScript/Node.js—for example, $ node -e "console.log(new Date());". 8 Chapter 1 ■ Setting up Node.js and Other Essentials If the Node.js program uses environmental variables, it’s possible to set them right before the node command. For example:   $ NODE_ENV=production API_KEY=442CC1FE-4333-46CE-80EE-6705A1896832

session, accessToken, accessTokenSecret, twitterUserMetadata) { var promise = this.Promise(); process.nextTick(function(){ if (twitterUserMetadata.screen_name === 'azat_co') { session.user = twitterUserMetadata; session.admin = true; } promise.fulfill(twitterUserMetadata); }) return promise; } ) .redirectPath('/admin');   everyauth.everymodule.handleLogout(routes.user.logout); everyauth.everymodule.findUserById(function (user, callback) { callback(user); });   var app = express();

Download sample

Download