SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Node.js (Advanced)




      Suresh Reddy
      Senior Software Engineer
      Echidna, Inc.
Agenda

    What is Node.JS

    Using Node.JS

    Common Modules

    Streams

    Express

    Load balancing

    Competitors

    References
What is Node.JS


    JavaScript programming environment for creating highly
    scalable network programs

    Provides evented, Non-blocking I/O

    Built on top of V8



     Node.JS is bare bone and the community are making stuff
      like Express, connect etc.
What is Node.JS
Event driven programming
       $.ajax(
         url:'http://example.com/getProducts?cid=132867',
         type:'GET',
         contentType:'application/json',
         success:function(response){// doWithResponse
         },
         error:function(xhr){// Error :(
         }
    );
Using Node.JS

    Install Node.JS
       
          wget http://nodejs.org/dist/node-v0.1.96.tar.gz
      
          gunzip node-v0.1.96.tar.gz
      
          cd node
      
          ./configure
      
          make
      
          make install

    NPM
      
          Install/Publish other modules you want by doing
      
          npm install <module_name>
      
          npm publish <module_name>
Node.JS – as an interactive shell
Similar to Python’s shell


$> node
>3+1
4
> true != false
true
>.help
>.exit
Node.JS – As a server
var http = require('http');
http.createServer(function (req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/plain'
    });
    res.end('Hello Worldn');
}).listen(1337, "127.0.0.1");


console.log('Server running at
127.0.0.1:1337');
Core Modules


    Processes

    Filesystem

    Networking

    Utilities


The entire list can be found at http://nodejs.org/api/
Core Modules - Processes
Node allows you to analyze your process and manage external
 process


Available Modules


    process

    child_process
Core Modules - Filesystem
Low level API to manipulate files


Available Modules


    fs

    path
Core Modules - Networking
 Available Modules

 
     net
 
     dgram
 
     http
 
     tls
 
     https
 
     dns
Express

    Basic web framework

    Runs on top of Node.js

    Provides routing and redirection helpers

    Dynamic view helpers

    Has support for session

    Focus on high performance
Hello World Express App
Streams

    Stream instances are Unix pipes

    Readable
       
         must emit ”data” events whenever they have data to be
         read and ”end” when the data stream is finished.

    Writable
      
         must implement the write() method to accept new data
         chunks into the stream and the end() method to instruct
         the stream that the data is finished.
Node.JS is useful for..

    Writing highly concurrent server applications

    Sharing application logic between server and client

    Peer-to-peer web applications using websockets

    Real-time applications
Load Balancing
The ability to distribute work load across multiple servers


    HAProxy

    Nginix

    Apache Http server
Other Asynchronous JavaScript
platforms


    Tornado and Twisted for Python

    Perl Object Environment for Perl

    libevent for C

    Vert.x for Java

    EventMachine for Ruby

    vibe.d for D
Links


    http://nodejs.org

    http://npmjs.org

    http://expressjs.com

    http://socket.io
Thank you

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Building HTTP API's with NodeJS and MongoDB
Building HTTP API's with NodeJS and MongoDBBuilding HTTP API's with NodeJS and MongoDB
Building HTTP API's with NodeJS and MongoDB
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDB
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 
Node js Modules and Event Emitters
Node js Modules and Event EmittersNode js Modules and Event Emitters
Node js Modules and Event Emitters
 
Containers > VMs
Containers > VMsContainers > VMs
Containers > VMs
 
Node.js tutoria for beginner
Node.js tutoria for beginnerNode.js tutoria for beginner
Node.js tutoria for beginner
 
NodeJS
NodeJSNodeJS
NodeJS
 
Node Session - 1
Node Session - 1Node Session - 1
Node Session - 1
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Best node js course
Best node js courseBest node js course
Best node js course
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 
NodeJS
NodeJSNodeJS
NodeJS
 
Node JS Crash Course
Node JS Crash CourseNode JS Crash Course
Node JS Crash Course
 
Node
NodeNode
Node
 
Node.js concurrency
Node.js concurrencyNode.js concurrency
Node.js concurrency
 
Nodejs
NodejsNodejs
Nodejs
 
Node.js for beginner
Node.js for beginnerNode.js for beginner
Node.js for beginner
 
Running Node Applications on iOS and Android
Running Node Applications on iOS and AndroidRunning Node Applications on iOS and Android
Running Node Applications on iOS and Android
 
Node js Introduction
Node js IntroductionNode js Introduction
Node js Introduction
 
Nodejs basics
Nodejs basicsNodejs basics
Nodejs basics
 

Andere mochten auch

The MEAN stack - SoCalCodeCamp - june 29th 2014
The MEAN stack - SoCalCodeCamp - june 29th 2014The MEAN stack - SoCalCodeCamp - june 29th 2014
The MEAN stack - SoCalCodeCamp - june 29th 2014Simona Clapan
 
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.jsThe MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.jsMongoDB
 
Avoiding Callback Hell From JavaScript
Avoiding Callback Hell From JavaScriptAvoiding Callback Hell From JavaScript
Avoiding Callback Hell From JavaScriptSarunyhot Suwannachoti
 
Nodejs quick start
Nodejs quick startNodejs quick start
Nodejs quick startGuangyao Cao
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-upTroy Miles
 
Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture AppDynamics
 

Andere mochten auch (9)

Build App with Nodejs - YWC Workshop
Build App with Nodejs - YWC WorkshopBuild App with Nodejs - YWC Workshop
Build App with Nodejs - YWC Workshop
 
The MEAN stack - SoCalCodeCamp - june 29th 2014
The MEAN stack - SoCalCodeCamp - june 29th 2014The MEAN stack - SoCalCodeCamp - june 29th 2014
The MEAN stack - SoCalCodeCamp - june 29th 2014
 
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.jsThe MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
The MEAN Stack: MongoDB, ExpressJS, AngularJS and Node.js
 
Avoiding Callback Hell From JavaScript
Avoiding Callback Hell From JavaScriptAvoiding Callback Hell From JavaScript
Avoiding Callback Hell From JavaScript
 
The future of node
The future of nodeThe future of node
The future of node
 
Nodejs quick start
Nodejs quick startNodejs quick start
Nodejs quick start
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-up
 
Node ppt
Node pptNode ppt
Node ppt
 
Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture Anatomy of a Modern Node.js Application Architecture
Anatomy of a Modern Node.js Application Architecture
 

Ähnlich wie Node js beginner

Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015Nir Noy
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDDSudar Muthu
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tourcacois
 
Introduction to node.js By Ahmed Assaf
Introduction to node.js  By Ahmed AssafIntroduction to node.js  By Ahmed Assaf
Introduction to node.js By Ahmed AssafAhmed Assaf
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginnersEnoch Joshua
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.pptWalaSidhom1
 
Top 30 Node.js interview questions
Top 30 Node.js interview questionsTop 30 Node.js interview questions
Top 30 Node.js interview questionstechievarsity
 
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...Codemotion
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comVan-Duyet Le
 
Node.js 101 with Rami Sayar
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami SayarFITC
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsWinston Hsieh
 
Node js introduction
Node js introductionNode js introduction
Node js introductionAlex Su
 

Ähnlich wie Node js beginner (20)

Node.js Workshop - Sela SDP 2015
Node.js Workshop  - Sela SDP 2015Node.js Workshop  - Sela SDP 2015
Node.js Workshop - Sela SDP 2015
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Introduction to node.js GDD
Introduction to node.js GDDIntroduction to node.js GDD
Introduction to node.js GDD
 
Node.js: A Guided Tour
Node.js: A Guided TourNode.js: A Guided Tour
Node.js: A Guided Tour
 
Introduction to node.js By Ahmed Assaf
Introduction to node.js  By Ahmed AssafIntroduction to node.js  By Ahmed Assaf
Introduction to node.js By Ahmed Assaf
 
Proposal
ProposalProposal
Proposal
 
Nodejs
NodejsNodejs
Nodejs
 
Node JS | Dilkash Shaikh Mahajan
Node JS | Dilkash Shaikh MahajanNode JS | Dilkash Shaikh Mahajan
Node JS | Dilkash Shaikh Mahajan
 
Introduction to Node.JS
Introduction to Node.JSIntroduction to Node.JS
Introduction to Node.JS
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginners
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
Top 30 Node.js interview questions
Top 30 Node.js interview questionsTop 30 Node.js interview questions
Top 30 Node.js interview questions
 
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
 
Node.js 101 with Rami Sayar
Node.js 101 with Rami SayarNode.js 101 with Rami Sayar
Node.js 101 with Rami Sayar
 
Node36
Node36Node36
Node36
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
node.js.pptx
node.js.pptxnode.js.pptx
node.js.pptx
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 

Node js beginner

  • 1. Node.js (Advanced) Suresh Reddy Senior Software Engineer Echidna, Inc.
  • 2. Agenda  What is Node.JS  Using Node.JS  Common Modules  Streams  Express  Load balancing  Competitors  References
  • 3. What is Node.JS  JavaScript programming environment for creating highly scalable network programs  Provides evented, Non-blocking I/O  Built on top of V8 Node.JS is bare bone and the community are making stuff like Express, connect etc.
  • 4. What is Node.JS Event driven programming $.ajax( url:'http://example.com/getProducts?cid=132867', type:'GET', contentType:'application/json', success:function(response){// doWithResponse }, error:function(xhr){// Error :( } );
  • 5. Using Node.JS  Install Node.JS  wget http://nodejs.org/dist/node-v0.1.96.tar.gz  gunzip node-v0.1.96.tar.gz  cd node  ./configure  make  make install  NPM  Install/Publish other modules you want by doing  npm install <module_name>  npm publish <module_name>
  • 6. Node.JS – as an interactive shell Similar to Python’s shell $> node >3+1 4 > true != false true >.help >.exit
  • 7. Node.JS – As a server var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello Worldn'); }).listen(1337, "127.0.0.1"); console.log('Server running at 127.0.0.1:1337');
  • 8. Core Modules  Processes  Filesystem  Networking  Utilities The entire list can be found at http://nodejs.org/api/
  • 9. Core Modules - Processes Node allows you to analyze your process and manage external process Available Modules  process  child_process
  • 10. Core Modules - Filesystem Low level API to manipulate files Available Modules  fs  path
  • 11. Core Modules - Networking Available Modules  net  dgram  http  tls  https  dns
  • 12. Express  Basic web framework  Runs on top of Node.js  Provides routing and redirection helpers  Dynamic view helpers  Has support for session  Focus on high performance
  • 14. Streams  Stream instances are Unix pipes  Readable  must emit ”data” events whenever they have data to be read and ”end” when the data stream is finished.  Writable  must implement the write() method to accept new data chunks into the stream and the end() method to instruct the stream that the data is finished.
  • 15. Node.JS is useful for..  Writing highly concurrent server applications  Sharing application logic between server and client  Peer-to-peer web applications using websockets  Real-time applications
  • 16. Load Balancing The ability to distribute work load across multiple servers  HAProxy  Nginix  Apache Http server
  • 17. Other Asynchronous JavaScript platforms  Tornado and Twisted for Python  Perl Object Environment for Perl  libevent for C  Vert.x for Java  EventMachine for Ruby  vibe.d for D
  • 18. Links  http://nodejs.org  http://npmjs.org  http://expressjs.com  http://socket.io