SlideShare a Scribd company logo
Getting started with
What is NodeJS ?
NodeJS is a platform built on Google’s V8
javascript engine for easily building scalable
network applications.
Advantages
  Event driven
  Nonblocking I/O Model
  Perfect for data intensive real time applications
  Lightweight and efficient
More about NodeJS
Is it all about developing server side code with
Javascript ?
Javascript provides an interface to V8.
What is this buzz about Google’s V8 javascript engine ?
  Powers Google Chrome.
  Translates javascript to assembly code
  Crankshaft JIT compiler
How is NodeJS different from other scripting
paradigms like Perl/PHP/Python/Ruby on Rails?
  Non Blocking
  Single threaded
  In built event based approach
Traditional I/O
Traditional I/O
Event based Non-Blocking I/O
How Non-Blocking I/O helps ?
                                       E
var mysql = require('db-mysql');       r
new mysql.Database(                    o
{                                      r
hostname: 'localhost‘,user: 'root‘,
password: '‘, database: 'kino_badge’}).on('error', function(error) {
     console.log('ERROR: ' + error);
}).on('ready', function(server) {            On Ready
    console.log('Connected to ' + server.hostname + ' (' + server.version + ')');
}).connect(function(error){
     if(error){
                                     connected
       console.log("connection error " + error);
     }
 this.query().select('*').from('appUser').execute(function(error,rows,columns){
       if(error){
         console.log("Error: " + error);                       R
         return;
       }                                                       e
       console.log("Rows : " + JSON.stringify(rows));          s
     });                                                       u
});
                                                              l
                                                              t
Why Javascript is the chosen one ?
 Inherently single threaded.
 Functions and Closures are available as first
 class objects
 No preconceived notions about I/O
 Event orientation at its core
 Present everywhere
   Browsers
   Webkits
NodeJS community and NPM
What is NPM
  Node packaged module.
  Third party Libraries, can be used with nodejs
What all modules are available for application
development
  16762 open source libraries available, and counting.
To install dependencies using NPM
  Any package can be installed using npm install
  Full instruction set can be referred at
  https://npmjs.org/doc/install.html
NodeJS
NodeJS in real world !!
• Linked-In Mobile app.
• Four Square Application
Want to program in                     ?
Be event oriented
Think in terms of callbacks on event
completion and error occurrences
Design using closures and callbacks
Let’s code with
A hello world program

A http server

List files on server
How callback works ?


console.log(‘Hello’);
setTimeout(function(){      callback
 console.log(‘World’);
},2000);
Callbacks revisited..

 var http = require("http");             HTTP Module

Create Server
 http.createServer(
     function(request,response){      Callback on request
         response.writeHead(200,{'Content-Type'
   : 'text/plain'});
         response.end("Hi I am running on
   NodeJSn");
     }
 ).listen(8124,'127.0.0.1');      Listen to Port

 console.log("server running at
   http://localhost:8124");
Detailed Example
var fs = require('fs');
var express = require('express');
var app = express(); app.listen(3000);

fs.readdir('../',function(err,files){
         console.log(files.length);
});
app.get('/file/index/:user', function(request, response) {
var user_directory = request.params.user;
fs.readdir(user_directory,function(err,files){
         if(err){
                      console.log(err);
                      response.send(JSON.stringify(err));
         }else{
response.set('Content-Type', 'text/html');
var dyna_html =
  '<html><head></head><body><table style="width:100px; height;200px;border: 1px solid black;">';
for(var i=0;i<files.length;i++){
         var dyna_col = '<tr><td>'+files[i]+'</td></tr>'
         dyna_html += dyna_col;
}
 dyna_html +='</table></body></html>';
 response.send(200, dyna_html); }});});
Let’s break with NodeJS
How to break with NodeJS
  Programming modularly
  Developing larger applications
Developing for the Web



                        ExpressJS


            MVC                     REST
Simple Examples
exports.world = function(){
  return 'hello world';
                                    hello.js
};




  var hello = require('./hello');
  var sys = require('util');
  sys.puts(hello.world());
                                    app.js
Complete JavaScript EcoSystem
Developing REST based Web app with
ExpressJS
Adding persistence layer with MongoDB
Managing security with OAuth using
  Google - PassportJS
  Facebook - facebook-node-sdk
Communicating with the Client side javascript
implemented in SmartClientJS
Questions…
Alok Guha                             Hussain Pithawala

      aalokism                             hussainpw

http://in.linkedin.com/in/alokguha   http://in.linkedin.com/in/hussainpithawala
Ad

More Related Content

What's hot (20)

Json Web Token - JWT
Json Web Token - JWTJson Web Token - JWT
Json Web Token - JWT
Prashant Walke
 
우아한 모노리스
우아한 모노리스우아한 모노리스
우아한 모노리스
Arawn Park
 
Asynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & PromisesAsynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & Promises
Hùng Nguyễn Huy
 
Spring boot
Spring bootSpring boot
Spring boot
Pradeep Shanmugam
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
Shaul Rosenzwieg
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web API
Brad Genereaux
 
React js
React jsReact js
React js
Oswald Campesato
 
Spring boot
Spring bootSpring boot
Spring boot
sdeeg
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
Jeevesh Pandey
 
Threading in C#
Threading in C#Threading in C#
Threading in C#
Medhat Dawoud
 
Introduction Node.js
Introduction Node.jsIntroduction Node.js
Introduction Node.js
Erik van Appeldoorn
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
orkaplan
 
Spring boot
Spring bootSpring boot
Spring boot
Gyanendra Yadav
 
C# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTC# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENT
Dr. Awase Khirni Syed
 
Reactjs Basics
Reactjs BasicsReactjs Basics
Reactjs Basics
Hamid Ghorbani
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
Bo-Yi Wu
 
Flutter
FlutterFlutter
Flutter
Dave Chao
 
An Introduction to OAuth 2
An Introduction to OAuth 2An Introduction to OAuth 2
An Introduction to OAuth 2
Aaron Parecki
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPM
Bhargav Anadkat
 
Lombok
LombokLombok
Lombok
Amit Aggarwal
 

Viewers also liked (7)

Design patterns
Design patternsDesign patterns
Design patterns
Alok Guha
 
Java Script Promise
Java Script PromiseJava Script Promise
Java Script Promise
Alok Guha
 
Express JS
Express JSExpress JS
Express JS
Alok Guha
 
Jasmine
JasmineJasmine
Jasmine
Alok Guha
 
Portfolio Undefined
Portfolio UndefinedPortfolio Undefined
Portfolio Undefined
<Undefined>
 
Q unit
Q unitQ unit
Q unit
Alok Guha
 
Aglie estimation and planning
Aglie estimation and planningAglie estimation and planning
Aglie estimation and planning
Alok Guha
 
Design patterns
Design patternsDesign patterns
Design patterns
Alok Guha
 
Java Script Promise
Java Script PromiseJava Script Promise
Java Script Promise
Alok Guha
 
Portfolio Undefined
Portfolio UndefinedPortfolio Undefined
Portfolio Undefined
<Undefined>
 
Aglie estimation and planning
Aglie estimation and planningAglie estimation and planning
Aglie estimation and planning
Alok Guha
 
Ad

Similar to NodeJS (20)

Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
Ricardo Silva
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
soft-shake.ch
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.
Mike Brevoort
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
Alex Su
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
Apaichon Punopas
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
Oleg Podsechin
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
David Padbury
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talk
Aarti Parikh
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Vikash Singh
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
Node js
Node jsNode js
Node js
hazzaz
 
Event driven programming -- Node.JS
Event driven programming -- Node.JSEvent driven programming -- Node.JS
Event driven programming -- Node.JS
Dimitri Teravanessian
 
Future Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NETFuture Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NET
Gianluca Carucci
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
Ben Lin
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Somkiat Puisungnoen
 
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
GITS Indonesia
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin Shanghai
Jackson Tian
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
guileen
 
Node intro
Node introNode intro
Node intro
cloudhead
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
Ricardo Silva
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
soft-shake.ch
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
Node.js - async for the rest of us.
Node.js - async for the rest of us.Node.js - async for the rest of us.
Node.js - async for the rest of us.
Mike Brevoort
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
Alex Su
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
David Padbury
 
Original slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talkOriginal slides from Ryan Dahl's NodeJs intro talk
Original slides from Ryan Dahl's NodeJs intro talk
Aarti Parikh
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Vikash Singh
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
Node js
Node jsNode js
Node js
hazzaz
 
Future Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NETFuture Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NET
Gianluca Carucci
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
Ben Lin
 
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...
GITS Indonesia
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin Shanghai
Jackson Tian
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
guileen
 
Ad

Recently uploaded (20)

TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 

NodeJS

  • 2. What is NodeJS ? NodeJS is a platform built on Google’s V8 javascript engine for easily building scalable network applications. Advantages Event driven Nonblocking I/O Model Perfect for data intensive real time applications Lightweight and efficient
  • 3. More about NodeJS Is it all about developing server side code with Javascript ? Javascript provides an interface to V8. What is this buzz about Google’s V8 javascript engine ? Powers Google Chrome. Translates javascript to assembly code Crankshaft JIT compiler How is NodeJS different from other scripting paradigms like Perl/PHP/Python/Ruby on Rails? Non Blocking Single threaded In built event based approach
  • 7. How Non-Blocking I/O helps ? E var mysql = require('db-mysql'); r new mysql.Database( o { r hostname: 'localhost‘,user: 'root‘, password: '‘, database: 'kino_badge’}).on('error', function(error) { console.log('ERROR: ' + error); }).on('ready', function(server) { On Ready console.log('Connected to ' + server.hostname + ' (' + server.version + ')'); }).connect(function(error){ if(error){ connected console.log("connection error " + error); } this.query().select('*').from('appUser').execute(function(error,rows,columns){ if(error){ console.log("Error: " + error); R return; } e console.log("Rows : " + JSON.stringify(rows)); s }); u }); l t
  • 8. Why Javascript is the chosen one ? Inherently single threaded. Functions and Closures are available as first class objects No preconceived notions about I/O Event orientation at its core Present everywhere Browsers Webkits
  • 9. NodeJS community and NPM What is NPM Node packaged module. Third party Libraries, can be used with nodejs What all modules are available for application development 16762 open source libraries available, and counting. To install dependencies using NPM Any package can be installed using npm install Full instruction set can be referred at https://npmjs.org/doc/install.html
  • 11. NodeJS in real world !! • Linked-In Mobile app. • Four Square Application
  • 12. Want to program in ? Be event oriented Think in terms of callbacks on event completion and error occurrences Design using closures and callbacks
  • 13. Let’s code with A hello world program A http server List files on server
  • 14. How callback works ? console.log(‘Hello’); setTimeout(function(){ callback console.log(‘World’); },2000);
  • 15. Callbacks revisited.. var http = require("http"); HTTP Module Create Server http.createServer( function(request,response){ Callback on request response.writeHead(200,{'Content-Type' : 'text/plain'}); response.end("Hi I am running on NodeJSn"); } ).listen(8124,'127.0.0.1'); Listen to Port console.log("server running at http://localhost:8124");
  • 16. Detailed Example var fs = require('fs'); var express = require('express'); var app = express(); app.listen(3000); fs.readdir('../',function(err,files){ console.log(files.length); }); app.get('/file/index/:user', function(request, response) { var user_directory = request.params.user; fs.readdir(user_directory,function(err,files){ if(err){ console.log(err); response.send(JSON.stringify(err)); }else{ response.set('Content-Type', 'text/html'); var dyna_html = '<html><head></head><body><table style="width:100px; height;200px;border: 1px solid black;">'; for(var i=0;i<files.length;i++){ var dyna_col = '<tr><td>'+files[i]+'</td></tr>' dyna_html += dyna_col; } dyna_html +='</table></body></html>'; response.send(200, dyna_html); }});});
  • 17. Let’s break with NodeJS How to break with NodeJS Programming modularly Developing larger applications Developing for the Web ExpressJS MVC REST
  • 18. Simple Examples exports.world = function(){ return 'hello world'; hello.js }; var hello = require('./hello'); var sys = require('util'); sys.puts(hello.world()); app.js
  • 19. Complete JavaScript EcoSystem Developing REST based Web app with ExpressJS Adding persistence layer with MongoDB Managing security with OAuth using Google - PassportJS Facebook - facebook-node-sdk Communicating with the Client side javascript implemented in SmartClientJS
  • 21. Alok Guha Hussain Pithawala aalokism hussainpw http://in.linkedin.com/in/alokguha http://in.linkedin.com/in/hussainpithawala