SlideShare a Scribd company logo
1 of 26
Download to read offline
NODE JS INTRODUCTION
Vatsal Shah
Software Embedded Engineer
Deeps Technology
www.vatsalshah.in
Introduction: Basic
 In simple words Node.js is ‘server-side JavaScript’.
 In not-so-simple words Node.js is a high-performance network
applications framework, well optimized for high concurrent
environments.
 It’s a command line tool.
 In ‘Node.js’ , ‘.js’ doesn’t mean that its solely written JavaScript. It is
40% JS and 60% C++.
 From the official site:
‘Node's goal is to provide an easy way to build scalable network programs’
- (from nodejs.org!)
11/16/2016
2
Vatsal Shah | Node Js
Why node.js ?
 Non Blocking I/O
 V8 Java script Engine
 Single Thread with Event Loop
 40,025 modules
 Windows, Linux, Mac
 1 Language for Frontend and Backend
 Active community
11/16/2016
3
Vatsal Shah | Node Js
Why node.js ?
Build Fast!
 JS on server and client allows
for more code reuse
 A lite stack (quick create-test
cycle)
 Large number of offerings for
web app creation
11/16/2016
4
Vatsal Shah | Node Js
Why node.js ?
 JS across stack allows easier
refactoring
 Smaller codebase
 See #1 (Build Fast!)
Adapt Fast!
11/16/2016
5
Vatsal Shah | Node Js
Why node.js ?
Run Fast!  Fast V8 Engine
 Great I/O performance with
event loop!
 Small number of layers
11/16/2016
6
Vatsal Shah | Node Js
Why node.js use event-based?
In a normal process cycle the web server while processing the request
will have to wait for the IO operations and thus blocking the next
request to be processed.
Node.JS process each request as events, The server doesn’t wait for
the IO operation to complete while it can handle other request at the
same time.
When the IO operation of first request is completed it will call-back
the server to complete the request.
11/16/2016
7
Vatsal Shah | Node Js
HTTP Method
 GET
 POST
 PUT
 DELETE
 GET => Read
 POST => Create
 PUT => Update
 DELETE => Delete
11/16/2016
8
Vatsal Shah | Node Js
Node.js Event Loop
11/16/2016
9
Vatsal Shah | Node Js
There are a couple of implications of this apparently very simple and basic model
• Avoid synchronous code at all costs because it blocks the event loop
• Which means: callbacks, callbacks, and more callbacks
Blocking vs. Non-Blocking
Example :: Read data from file and show data
11/16/2016
10
Vatsal Shah | Node Js
Blocking
Read data from file
Show data
Do other tasks
var data = fs.readFileSync( “test.txt” );
console.log( data );
console.log( “Do other tasks” );
11/16/2016
11
Vatsal Shah | Node Js
Non-Blocking
 Read data from file
When read data completed, show data
 Do other tasks
fs.readFile( “test.txt”, function( err, data ) {
console.log(data);
});
11/16/2016
12
Vatsal Shah | Node Js
Node.js Modules
 https://npmjs.org/
 # of modules = 1,21,943
11/16/2016
13
Vatsal Shah | Node Js
Modules
 $npm install <module name>
 Modules allow Node to be extended (act as libaries)
 We can include a module with the global require function, require(‘module’)
 Node provides core modules that can be included by their name:
 File System – require(‘fs’)
 Http – require(‘http’)
 Utilities – require(‘util’)
11/16/2016
14
Vatsal Shah | Node Js
Modules
 We can also break our application up into modules and require
them using a file path:
 ‘/’ (absolute path), ‘./’ and ‘../’ (relative to calling file)
 Any valid type can be exported from a module by assigning it to
module.exports
11/16/2016
15
Vatsal Shah | Node Js
NPM Versions
 Var Versions (version [Major].[Minor].[Patch]):
 = (default), >, <, >=, <=
 * most recent version
 1.2.3 – 2.3.4 version greater than 1.2.3 and less than 2.3.4
 ~1.2.3 most recent patch version greater than or equal to 1.2.3 (>=1.2.3 <1.3.0)
 ^1.2.3 most recent minor version greater than or equal to 1.2.3 (>=1.2.3 <2.0.0)
11/16/2016
16
Vatsal Shah | Node Js
NPM Commands
 Common npm commands:
 npm init initialize a package.json file
 npm install <package name> -g install a package, if –g option is given package
will be installed as a global, --save and --save-dev will add package to your dependencies
 npm install install packages listed in package.json
 npm ls –g listed local packages (without –g) or global packages (with –g)
 npm update <package name> update a package
11/16/2016
17
Vatsal Shah | Node Js
File package.json
 First, we need to create a package.json file for our app
 Contains metadata for our app and lists the dependencies
 Package.json Interactive Guide
Project informations
 Name
 Version
 Dépendances
 Licence
 Main file
Etc...
11/16/2016
18
Vatsal Shah | Node Js
Example-1: Getting Started & Hello World
 Install/build Node.js.
 (Yes! Windows installer is available!)
 Open your favorite editor and start typing JavaScript.
 When you are done, open cmd/terminal and type this:
node YOUR_FILE.js
 Here is a simple example, which prints ‘hello world’
var sys = require sys ;
setTimeout(function(){
sys.puts world ;},3000 ;
sys.puts hello ;
//it prints hello first and waits for 3 seconds and then prints world
11/16/2016
19
Vatsal Shah | Node Js
Node.js Ecosystem
 Node.js heavily relies on modules, in previous examples require keyword
loaded the http & net modules.
 Creating a module is easy, just put your JavaScript code in a separate js
file and include it in your code by using keyword require, like:
var modulex = require ./modulex ;
 Libraries in Node.js are called packages and they can be installed by
typing
npm install package_name ; //package should be available in npm registry @
nmpjs.org
 NPM (Node Package Manager) comes bundled with Node.js installation.
11/16/2016
20
Vatsal Shah | Node Js
Example -2 &3 (HTTP Server & TCP Server)
 Following code creates an HTTP Server and prints ‘Hello World’ on the browser:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Worldn'); }).listen(5000, "127.0.0.1");
 Here is an example of a simple TCP server which listens on port 6000 and echoes whatever you send it:
var net = require('net');
net.createServer(function (socket) {
socket.write("Echo serverrn");
socket.pipe(socket); }).listen(6000, "127.0.0.1");
11/16/2016
21
Vatsal Shah | Node Js
Example-4: Lets connect to a DB (MongoDB)
 Install mongojs using npm, a mongoDB driver for Node.js
npm install mongojs
 Code to retrieve all the documents from a collection:
var db = require("mongojs")
.connect("localhost:27017/test", ['test']);
db.test.find({}, function(err, posts) {
if( err || !posts) console.log("No posts found");
else posts.forEach( function(post) {
console.log(post);
});
});
11/16/2016
22
Vatsal Shah | Node Js
When to use it ?
 Chat/Messaging
 Real-time Applications
 High Concurrency Applications
 Coordinators
 Web application
 Streaming server
 Fast file upload client
 Any Real-time data apps
 Anything with high I/O
11/16/2016
23
Vatsal Shah | Node Js
Who is using Node.js in production?
11/16/2016
24
Vatsal Shah | Node Js
Getting Started
 http://nodejs.org/ and Download tar.gz
 Extract to any directory
 $ ./configure && make install
11/16/2016
25
Vatsal Shah | Node Js
Thank You 

More Related Content

What's hot

Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.jsDinesh U
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBhargav Anadkat
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js ExpressEyal Vardi
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsRob O'Doherty
 
Asynchronous JavaScript Programming
Asynchronous JavaScript ProgrammingAsynchronous JavaScript Programming
Asynchronous JavaScript ProgrammingHaim Michael
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginnersEnoch Joshua
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners Varun Raj
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.jsEmanuele DelBono
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...Edureka!
 

What's hot (20)

Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPM
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Express JS
Express JSExpress JS
Express JS
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
Asynchronous JavaScript Programming
Asynchronous JavaScript ProgrammingAsynchronous JavaScript Programming
Asynchronous JavaScript Programming
 
NodeJS guide for beginners
NodeJS guide for beginnersNodeJS guide for beginners
NodeJS guide for beginners
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
 
An Overview on Nuxt.js
An Overview on Nuxt.jsAn Overview on Nuxt.js
An Overview on Nuxt.js
 
Node js for beginners
Node js for beginnersNode js for beginners
Node js for beginners
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
 
Node.js Basics
Node.js Basics Node.js Basics
Node.js Basics
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Node js
Node jsNode js
Node js
 
Express js
Express jsExpress js
Express js
 
Node.js Express Framework
Node.js Express FrameworkNode.js Express Framework
Node.js Express Framework
 
Basics of VueJS
Basics of VueJSBasics of VueJS
Basics of VueJS
 
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
 

Viewers also liked

Poster IOTROBOT vatsalnshah_ec_indusuniversity
Poster IOTROBOT vatsalnshah_ec_indusuniversityPoster IOTROBOT vatsalnshah_ec_indusuniversity
Poster IOTROBOT vatsalnshah_ec_indusuniversityVatsal N Shah
 
Presentation IOT Robot
Presentation IOT RobotPresentation IOT Robot
Presentation IOT RobotVatsal N Shah
 
From Hello World to Real World - Container Days Boston 2016
From Hello World to Real World - Container Days Boston 2016From Hello World to Real World - Container Days Boston 2016
From Hello World to Real World - Container Days Boston 2016Shannon Williams
 
Project ideas ece students
Project ideas ece studentsProject ideas ece students
Project ideas ece studentsVatsal N Shah
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
iot report 3 (2)
iot report 3 (2)iot report 3 (2)
iot report 3 (2)AISWARYA T
 
project report on IoT
project report on IoTproject report on IoT
project report on IoTAnshul Sahu
 
Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。Tatsuya Tobioka
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureColin Mackay
 
EmpireJS: Hacking Art with Node js and Image Analysis
EmpireJS: Hacking Art with Node js and Image AnalysisEmpireJS: Hacking Art with Node js and Image Analysis
EmpireJS: Hacking Art with Node js and Image Analysisjeresig
 
Report Automatic led emergency light
Report Automatic led emergency lightReport Automatic led emergency light
Report Automatic led emergency lightVatsal N Shah
 
pick-and-place-robot
pick-and-place-robotpick-and-place-robot
pick-and-place-robotSuchit Moon
 
ROBOTICS AND ITS APPLICATIONS
ROBOTICS AND ITS APPLICATIONSROBOTICS AND ITS APPLICATIONS
ROBOTICS AND ITS APPLICATIONSAnmol Seth
 

Viewers also liked (20)

Poster IOTROBOT vatsalnshah_ec_indusuniversity
Poster IOTROBOT vatsalnshah_ec_indusuniversityPoster IOTROBOT vatsalnshah_ec_indusuniversity
Poster IOTROBOT vatsalnshah_ec_indusuniversity
 
Presentation IOT Robot
Presentation IOT RobotPresentation IOT Robot
Presentation IOT Robot
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
From Hello World to Real World - Container Days Boston 2016
From Hello World to Real World - Container Days Boston 2016From Hello World to Real World - Container Days Boston 2016
From Hello World to Real World - Container Days Boston 2016
 
Project ideas ece students
Project ideas ece studentsProject ideas ece students
Project ideas ece students
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
iot report 3 (2)
iot report 3 (2)iot report 3 (2)
iot report 3 (2)
 
project report on IoT
project report on IoTproject report on IoT
project report on IoT
 
Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。
 
Node js meetup
Node js meetupNode js meetup
Node js meetup
 
Report IOT Robot
Report IOT RobotReport IOT Robot
Report IOT Robot
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure
 
EmpireJS: Hacking Art with Node js and Image Analysis
EmpireJS: Hacking Art with Node js and Image AnalysisEmpireJS: Hacking Art with Node js and Image Analysis
EmpireJS: Hacking Art with Node js and Image Analysis
 
Report Automatic led emergency light
Report Automatic led emergency lightReport Automatic led emergency light
Report Automatic led emergency light
 
Am fm transmitter
Am fm transmitterAm fm transmitter
Am fm transmitter
 
Search and rescue
Search and rescueSearch and rescue
Search and rescue
 
pick-and-place-robot
pick-and-place-robotpick-and-place-robot
pick-and-place-robot
 
Node JS
Node JSNode JS
Node JS
 
Internet of Things
Internet of ThingsInternet of Things
Internet of Things
 
ROBOTICS AND ITS APPLICATIONS
ROBOTICS AND ITS APPLICATIONSROBOTICS AND ITS APPLICATIONS
ROBOTICS AND ITS APPLICATIONS
 

Similar to Nodejs vatsal shah

Introduction to Node js for beginners + game project
Introduction to Node js for beginners + game projectIntroduction to Node js for beginners + game project
Introduction to Node js for beginners + game projectLaurence Svekis ✔
 
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
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comVan-Duyet Le
 
OSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshopOSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshopleffen
 
Halton Software Peer 2 Peer Meetup #10
Halton Software Peer 2 Peer Meetup #10Halton Software Peer 2 Peer Meetup #10
Halton Software Peer 2 Peer Meetup #10David Ashton
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsWinston Hsieh
 
Local SQLite Database with Node for beginners
Local SQLite Database with Node for beginnersLocal SQLite Database with Node for beginners
Local SQLite Database with Node for beginnersLaurence Svekis ✔
 
Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)Lucas Jellema
 
Node js (runtime environment + js library) platform
Node js (runtime environment + js library) platformNode js (runtime environment + js library) platform
Node js (runtime environment + js library) platformSreenivas Kappala
 
Introduction to node.js
Introduction to  node.jsIntroduction to  node.js
Introduction to node.jsMd. Sohel Rana
 

Similar to Nodejs vatsal shah (20)

Nodejs
NodejsNodejs
Nodejs
 
Introduction to Node js for beginners + game project
Introduction to Node js for beginners + game projectIntroduction to Node js for beginners + game project
Introduction to Node js for beginners + game project
 
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
 
Introduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.comIntroduce about Nodejs - duyetdev.com
Introduce about Nodejs - duyetdev.com
 
Node js beginner
Node js beginnerNode js beginner
Node js beginner
 
Node J pdf.docx
Node J pdf.docxNode J pdf.docx
Node J pdf.docx
 
Node J pdf.docx
Node J pdf.docxNode J pdf.docx
Node J pdf.docx
 
OSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshopOSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshop
 
Proposal
ProposalProposal
Proposal
 
NodeJS @ ACS
NodeJS @ ACSNodeJS @ ACS
NodeJS @ ACS
 
Halton Software Peer 2 Peer Meetup #10
Halton Software Peer 2 Peer Meetup #10Halton Software Peer 2 Peer Meetup #10
Halton Software Peer 2 Peer Meetup #10
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Local SQLite Database with Node for beginners
Local SQLite Database with Node for beginnersLocal SQLite Database with Node for beginners
Local SQLite Database with Node for beginners
 
Node js
Node jsNode js
Node js
 
Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)
 
Ferrara Linux Day 2011
Ferrara Linux Day 2011Ferrara Linux Day 2011
Ferrara Linux Day 2011
 
Node js first look - 2016
Node js first look - 2016Node js first look - 2016
Node js first look - 2016
 
Node js (runtime environment + js library) platform
Node js (runtime environment + js library) platformNode js (runtime environment + js library) platform
Node js (runtime environment + js library) platform
 
Nodejs
NodejsNodejs
Nodejs
 
Introduction to node.js
Introduction to  node.jsIntroduction to  node.js
Introduction to node.js
 

More from Vatsal N Shah

Machine Learning Project - Default credit card clients
Machine Learning Project - Default credit card clients Machine Learning Project - Default credit card clients
Machine Learning Project - Default credit card clients Vatsal N Shah
 
I am sharing my journey with Indus University and Indus Family. Read Page No:...
I am sharing my journey with Indus University and Indus Family. Read Page No:...I am sharing my journey with Indus University and Indus Family. Read Page No:...
I am sharing my journey with Indus University and Indus Family. Read Page No:...Vatsal N Shah
 
Floor cleaning robot(autonomus mannual) vatsal shah-ec_4th year
Floor cleaning robot(autonomus mannual)  vatsal shah-ec_4th yearFloor cleaning robot(autonomus mannual)  vatsal shah-ec_4th year
Floor cleaning robot(autonomus mannual) vatsal shah-ec_4th yearVatsal N Shah
 
Raspbeery Pi : An Introduction
Raspbeery Pi : An IntroductionRaspbeery Pi : An Introduction
Raspbeery Pi : An IntroductionVatsal N Shah
 
Report Remote communication of Robotic module using lifa
Report Remote communication of Robotic module using lifaReport Remote communication of Robotic module using lifa
Report Remote communication of Robotic module using lifaVatsal N Shah
 
Floor cleaning robot report vatsal shah_ec_7th sem
Floor cleaning robot report vatsal shah_ec_7th semFloor cleaning robot report vatsal shah_ec_7th sem
Floor cleaning robot report vatsal shah_ec_7th semVatsal N Shah
 
IRC Magazine Issue_1
IRC Magazine Issue_1IRC Magazine Issue_1
IRC Magazine Issue_1Vatsal N Shah
 
Advanced wheel chair vatsal shah
Advanced wheel chair   vatsal shah Advanced wheel chair   vatsal shah
Advanced wheel chair vatsal shah Vatsal N Shah
 
Configuring lifa for remote communication using web architecture
Configuring lifa for remote communication using web architectureConfiguring lifa for remote communication using web architecture
Configuring lifa for remote communication using web architectureVatsal N Shah
 
Control robotic module using LIFA
Control robotic module using LIFAControl robotic module using LIFA
Control robotic module using LIFAVatsal N Shah
 
E-sync-Revista-Editon-1
E-sync-Revista-Editon-1E-sync-Revista-Editon-1
E-sync-Revista-Editon-1Vatsal N Shah
 
GSM based lcd dsiplay
GSM based lcd dsiplayGSM based lcd dsiplay
GSM based lcd dsiplayVatsal N Shah
 
Project report format
Project report formatProject report format
Project report formatVatsal N Shah
 
Abstract - Interfacing 5 x7 matrix led display to 8051
Abstract - Interfacing 5 x7 matrix led display to 8051 Abstract - Interfacing 5 x7 matrix led display to 8051
Abstract - Interfacing 5 x7 matrix led display to 8051 Vatsal N Shah
 
5x7 matrix led display
5x7 matrix led display 5x7 matrix led display
5x7 matrix led display Vatsal N Shah
 
A seminar report on flex sensor
A seminar report on flex sensor A seminar report on flex sensor
A seminar report on flex sensor Vatsal N Shah
 

More from Vatsal N Shah (20)

Machine Learning Project - Default credit card clients
Machine Learning Project - Default credit card clients Machine Learning Project - Default credit card clients
Machine Learning Project - Default credit card clients
 
I am sharing my journey with Indus University and Indus Family. Read Page No:...
I am sharing my journey with Indus University and Indus Family. Read Page No:...I am sharing my journey with Indus University and Indus Family. Read Page No:...
I am sharing my journey with Indus University and Indus Family. Read Page No:...
 
Floor cleaning robot(autonomus mannual) vatsal shah-ec_4th year
Floor cleaning robot(autonomus mannual)  vatsal shah-ec_4th yearFloor cleaning robot(autonomus mannual)  vatsal shah-ec_4th year
Floor cleaning robot(autonomus mannual) vatsal shah-ec_4th year
 
Projects
ProjectsProjects
Projects
 
Raspbeery Pi : An Introduction
Raspbeery Pi : An IntroductionRaspbeery Pi : An Introduction
Raspbeery Pi : An Introduction
 
Report Remote communication of Robotic module using lifa
Report Remote communication of Robotic module using lifaReport Remote communication of Robotic module using lifa
Report Remote communication of Robotic module using lifa
 
Floor cleaning robot report vatsal shah_ec_7th sem
Floor cleaning robot report vatsal shah_ec_7th semFloor cleaning robot report vatsal shah_ec_7th sem
Floor cleaning robot report vatsal shah_ec_7th sem
 
IRC Magazine Issue_1
IRC Magazine Issue_1IRC Magazine Issue_1
IRC Magazine Issue_1
 
Advanced wheel chair vatsal shah
Advanced wheel chair   vatsal shah Advanced wheel chair   vatsal shah
Advanced wheel chair vatsal shah
 
Configuring lifa for remote communication using web architecture
Configuring lifa for remote communication using web architectureConfiguring lifa for remote communication using web architecture
Configuring lifa for remote communication using web architecture
 
Control robotic module using LIFA
Control robotic module using LIFAControl robotic module using LIFA
Control robotic module using LIFA
 
Trapatt diode
Trapatt diode Trapatt diode
Trapatt diode
 
Telemedicine
Telemedicine Telemedicine
Telemedicine
 
E-sync-Revista-Editon-1
E-sync-Revista-Editon-1E-sync-Revista-Editon-1
E-sync-Revista-Editon-1
 
GSM based lcd dsiplay
GSM based lcd dsiplayGSM based lcd dsiplay
GSM based lcd dsiplay
 
Project report format
Project report formatProject report format
Project report format
 
Abstract - Interfacing 5 x7 matrix led display to 8051
Abstract - Interfacing 5 x7 matrix led display to 8051 Abstract - Interfacing 5 x7 matrix led display to 8051
Abstract - Interfacing 5 x7 matrix led display to 8051
 
5x7 matrix led display
5x7 matrix led display 5x7 matrix led display
5x7 matrix led display
 
A seminar report on flex sensor
A seminar report on flex sensor A seminar report on flex sensor
A seminar report on flex sensor
 
Flex sensor
Flex sensor   Flex sensor
Flex sensor
 

Recently uploaded

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 

Recently uploaded (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

Nodejs vatsal shah

  • 1. NODE JS INTRODUCTION Vatsal Shah Software Embedded Engineer Deeps Technology www.vatsalshah.in
  • 2. Introduction: Basic  In simple words Node.js is ‘server-side JavaScript’.  In not-so-simple words Node.js is a high-performance network applications framework, well optimized for high concurrent environments.  It’s a command line tool.  In ‘Node.js’ , ‘.js’ doesn’t mean that its solely written JavaScript. It is 40% JS and 60% C++.  From the official site: ‘Node's goal is to provide an easy way to build scalable network programs’ - (from nodejs.org!) 11/16/2016 2 Vatsal Shah | Node Js
  • 3. Why node.js ?  Non Blocking I/O  V8 Java script Engine  Single Thread with Event Loop  40,025 modules  Windows, Linux, Mac  1 Language for Frontend and Backend  Active community 11/16/2016 3 Vatsal Shah | Node Js
  • 4. Why node.js ? Build Fast!  JS on server and client allows for more code reuse  A lite stack (quick create-test cycle)  Large number of offerings for web app creation 11/16/2016 4 Vatsal Shah | Node Js
  • 5. Why node.js ?  JS across stack allows easier refactoring  Smaller codebase  See #1 (Build Fast!) Adapt Fast! 11/16/2016 5 Vatsal Shah | Node Js
  • 6. Why node.js ? Run Fast!  Fast V8 Engine  Great I/O performance with event loop!  Small number of layers 11/16/2016 6 Vatsal Shah | Node Js
  • 7. Why node.js use event-based? In a normal process cycle the web server while processing the request will have to wait for the IO operations and thus blocking the next request to be processed. Node.JS process each request as events, The server doesn’t wait for the IO operation to complete while it can handle other request at the same time. When the IO operation of first request is completed it will call-back the server to complete the request. 11/16/2016 7 Vatsal Shah | Node Js
  • 8. HTTP Method  GET  POST  PUT  DELETE  GET => Read  POST => Create  PUT => Update  DELETE => Delete 11/16/2016 8 Vatsal Shah | Node Js
  • 9. Node.js Event Loop 11/16/2016 9 Vatsal Shah | Node Js There are a couple of implications of this apparently very simple and basic model • Avoid synchronous code at all costs because it blocks the event loop • Which means: callbacks, callbacks, and more callbacks
  • 10. Blocking vs. Non-Blocking Example :: Read data from file and show data 11/16/2016 10 Vatsal Shah | Node Js
  • 11. Blocking Read data from file Show data Do other tasks var data = fs.readFileSync( “test.txt” ); console.log( data ); console.log( “Do other tasks” ); 11/16/2016 11 Vatsal Shah | Node Js
  • 12. Non-Blocking  Read data from file When read data completed, show data  Do other tasks fs.readFile( “test.txt”, function( err, data ) { console.log(data); }); 11/16/2016 12 Vatsal Shah | Node Js
  • 13. Node.js Modules  https://npmjs.org/  # of modules = 1,21,943 11/16/2016 13 Vatsal Shah | Node Js
  • 14. Modules  $npm install <module name>  Modules allow Node to be extended (act as libaries)  We can include a module with the global require function, require(‘module’)  Node provides core modules that can be included by their name:  File System – require(‘fs’)  Http – require(‘http’)  Utilities – require(‘util’) 11/16/2016 14 Vatsal Shah | Node Js
  • 15. Modules  We can also break our application up into modules and require them using a file path:  ‘/’ (absolute path), ‘./’ and ‘../’ (relative to calling file)  Any valid type can be exported from a module by assigning it to module.exports 11/16/2016 15 Vatsal Shah | Node Js
  • 16. NPM Versions  Var Versions (version [Major].[Minor].[Patch]):  = (default), >, <, >=, <=  * most recent version  1.2.3 – 2.3.4 version greater than 1.2.3 and less than 2.3.4  ~1.2.3 most recent patch version greater than or equal to 1.2.3 (>=1.2.3 <1.3.0)  ^1.2.3 most recent minor version greater than or equal to 1.2.3 (>=1.2.3 <2.0.0) 11/16/2016 16 Vatsal Shah | Node Js
  • 17. NPM Commands  Common npm commands:  npm init initialize a package.json file  npm install <package name> -g install a package, if –g option is given package will be installed as a global, --save and --save-dev will add package to your dependencies  npm install install packages listed in package.json  npm ls –g listed local packages (without –g) or global packages (with –g)  npm update <package name> update a package 11/16/2016 17 Vatsal Shah | Node Js
  • 18. File package.json  First, we need to create a package.json file for our app  Contains metadata for our app and lists the dependencies  Package.json Interactive Guide Project informations  Name  Version  Dépendances  Licence  Main file Etc... 11/16/2016 18 Vatsal Shah | Node Js
  • 19. Example-1: Getting Started & Hello World  Install/build Node.js.  (Yes! Windows installer is available!)  Open your favorite editor and start typing JavaScript.  When you are done, open cmd/terminal and type this: node YOUR_FILE.js  Here is a simple example, which prints ‘hello world’ var sys = require sys ; setTimeout(function(){ sys.puts world ;},3000 ; sys.puts hello ; //it prints hello first and waits for 3 seconds and then prints world 11/16/2016 19 Vatsal Shah | Node Js
  • 20. Node.js Ecosystem  Node.js heavily relies on modules, in previous examples require keyword loaded the http & net modules.  Creating a module is easy, just put your JavaScript code in a separate js file and include it in your code by using keyword require, like: var modulex = require ./modulex ;  Libraries in Node.js are called packages and they can be installed by typing npm install package_name ; //package should be available in npm registry @ nmpjs.org  NPM (Node Package Manager) comes bundled with Node.js installation. 11/16/2016 20 Vatsal Shah | Node Js
  • 21. Example -2 &3 (HTTP Server & TCP Server)  Following code creates an HTTP Server and prints ‘Hello World’ on the browser: var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello Worldn'); }).listen(5000, "127.0.0.1");  Here is an example of a simple TCP server which listens on port 6000 and echoes whatever you send it: var net = require('net'); net.createServer(function (socket) { socket.write("Echo serverrn"); socket.pipe(socket); }).listen(6000, "127.0.0.1"); 11/16/2016 21 Vatsal Shah | Node Js
  • 22. Example-4: Lets connect to a DB (MongoDB)  Install mongojs using npm, a mongoDB driver for Node.js npm install mongojs  Code to retrieve all the documents from a collection: var db = require("mongojs") .connect("localhost:27017/test", ['test']); db.test.find({}, function(err, posts) { if( err || !posts) console.log("No posts found"); else posts.forEach( function(post) { console.log(post); }); }); 11/16/2016 22 Vatsal Shah | Node Js
  • 23. When to use it ?  Chat/Messaging  Real-time Applications  High Concurrency Applications  Coordinators  Web application  Streaming server  Fast file upload client  Any Real-time data apps  Anything with high I/O 11/16/2016 23 Vatsal Shah | Node Js
  • 24. Who is using Node.js in production? 11/16/2016 24 Vatsal Shah | Node Js
  • 25. Getting Started  http://nodejs.org/ and Download tar.gz  Extract to any directory  $ ./configure && make install 11/16/2016 25 Vatsal Shah | Node Js