Node.js

Node.js
 Node.js is a server-side platform built on Google Chrome's JavaScript Engine (V8 Engine). Node.js was developed by Ryan Dahl in 2009 and its latest version is v0.10.36.
 Node.js is an open source, cross-platform runtime environment for developing server-side and networking applications. Node.js applications are written in JavaScript, and can be run within the Node.js runtime on OS X, Microsoft Windows, and Linux. 
2.what Features of Node.js ?
* Asynchronous and Event Driven
* Very Fast
*Single Threaded but Highly Scalable
*No Buffering 
*License 

3.Who Uses Node.js?

* Following is the link on github wiki containing an exhaustive list of projects, application and companies which are using Node.js. This list includes eBay, General Electric, GoDaddy, Microsoft, PayPal, Uber, Wikipins, Yahoo!, and Yammer to name a few.



4.What Concepts are in Node.js?

* The following diagram depicts some important parts of Node.js which we will discuss in detail in the subsequent chapters.

Node.js Concepts
 
  
5.Where to Use Node.js?
  Following are the areas where Node.js is proving itself as a perfect technology    partner.
  • I/O bound Applications
  • Data Streaming Applications
  • Data Intensive Real-time Applications (DIRT)
  • JSON APIs based Applications
  • Single Page Applications



    --Node.js  modules-- 

     1.What is a Module in Node.js?

       * Consider modules to be the same as JavaScript libraries. 
         * A set of functions you want to include in your application.

    --Include Modules--

    * To include a module, use the require() function with the name of the module:

    1.var http = require('http'); 
    * Now your application has access to the HTTP module, and is able to create a server:
    http.createServer(function (req, res) {
        res.writeHead(200, {'Content-Type': 'text/html'});
        res.end('Hello World!');
    }).listen(8080); 

     

    --Create Your Own Modules--

    * You can create your own modules, and easily include them in your applications.
    * The following example creates a module that returns a date and time object:

    exports.myDateTime = function () {
        return Date();
    };  


    Use the exports keyword to make properties and methods available outside the module file.
    Save the code above in a file called "mycreatemodule.js"


    var http = require('http');
    var dt = require('./mycraetemodule');


    ** Include Your Own Module **

    http.createServer(function (req, res) {
        res.writeHead(200, {'Content-Type': 'text/html'});
        res.write("The date and time are currently: " + dt.myDateTime());
        res.end();
    }).listen(8080);



    Initiate demo_module.js:

    C:\Users\Your Name>node demo_module.js








 

Comments

Popular posts from this blog

How to build a Wall Mounted Family Calendar and Dashboard

Build a Node.js API

built web-app Authentication in React Applications