SlideShare ist ein Scribd-Unternehmen logo
1 von 41
BY
C.ENOCH JOSHUA
What’s I/O?
 Distance of data travel from input to output.
What is JavaScript ?
 It is dynamic programming language.
 It is client side script to interact with user.
 It most commonly used as a part of web browser
Background
 Node.js was invented in 2009 by Ryan Dahl
 inspired to create Node.js after seeing a file upload progress bar on
FLICKR
 Open source , sponsored by Joyent and Microsoft
 Ryan was a mathematics student and dropped out of college.
 Node.js runs on V8.
Introduction: Basic
What is NodeJS ?
 NodeJS is an open source , cross platform runtime environment for
server side and networking application.
 It is written in JavaScript and can run on Linux , Mac , Windows ,
FreeBSD.
 It provided an event driven architecture and a non blocking I/O that
optimize and scalability. These technology uses for real time application.
 It used Google JavaScript V8 Engine to Execute Code.
JavaScript V8 Engine
 The V8 JavaScript Engine is an open source JavaScript engine
developed by Google for the Google Chrome web browser.
 V8 compiles JavaScript to native machine code (IA-32, x86-64,
ARM, or MIPS ISAs) before executing it.
 V8 can run standalone, or can be embedded into any
C++ application
Why Use NodeJS?
 Node's goal is to provide an easy way to build scalable network programs.
What is unique about NodeJS?
 Using JavaScript on server-side making communication between client and
server will happen in same language.
 Servers are Event based serves each request in Evented Loop. So, it can
handle simultaneous requests.
Reasons touse NodeJS
 It is very lightweight and fast. There has been over 200,000 visits on
this website in three weeks and minimal server resources has been
able to handle it all.
 The counter is really easy to make to be real time.
 Node.js was easy to configure.
 There are lots of modules available for free.
 NodeJS work with NoSQL as well.
When not use NodeJS
 Your server request is dependent on heavy CPU consuming algorithm/Job.
NodeJS Setup
 Download at http://nodejs.org
 Set Environment variable (Last version automatic set)
 Open command line and type following.
node -v
What is Callback?
 Call-back is an asynchronous equivalent for a function.
 A call-back function is called at the completion of a given task.
 Node makes heavy use of call-backs.
Blocking I/O:
 Traditional applications waits for a set code to complete before it displays the
content. This is called blocking code.
Non blocking I/O:
 In non blocking Once the request is made we continue on to the next line of
code before waiting for the time consuming request to finish.
 Uses callback functions to handle non blocking code.
What makes node better?
Event driven
• Just like java script events on the client, Node can handle various events
on the server
• Examples of server events are file transfer , request for a page , loading
content from database
Node.js Event Loop
REPL Terminal
Read − Reads user's input, parses the input into JavaScript data-structure, and stores
in memory.
Eval − Takes and evaluates the data structure.
Print − Prints the result.
Loop − Loops the above command until the user presses ctrl-c twice.
Starting REPL
Simple Expression
node
>
node
> 1 + 3
4
>1 + ( 2 * 3 ) - 4
3
>
REPL Commands
ctrl + c − terminate the current command.
ctrl + c twice − terminate the Node REPL.
ctrl + d − terminate the Node REPL.
Up/Down Keys − see command history and modify previous commands.
tab Keys − list of current commands.
.help − list of all commands.
.break − exit from multiline expression.
.clear − exit from multiline expression.
.save filename − save the current Node REPL session to a file.
.load filename − load file content in current Node REPL session.
What is npm?
NPM
Easy for developers to share
and reuse code
Makes it easy to update the
code that you’re sharing
NPM Functionalities
Functionalities
Online
repositories
Command line
utility
To install
Version
management
Dependency management
The npm comes bundled with Node.js installables in versions after that v0.6.3.
You can check the version by command.
npm –v (or) npm version
Installing Modules using npm
Following is the syntax to install any Node.js module:
For example:
npm install <Module Name>
npm install express
Local Installation
Global Installation
• Local
Mode
Package
installation
• Node
module
accessible
• require()
command
• Npm ls
• Global
Mode
Package
installation
• System
Directory
Not-
accessible
• Require()
command
• Npm ls -
g
CLI
Uninstalling a Module
npm uninstall express
Updating a Module
npm update express
Search a Module
npm search express
BUFFER
 For an input operation, buffer mode will wait until all the data is collected
into a buffer
 and then pass it to a call-back as soon as the entire resource is read.
 In the below image you can see that when some data are received it is saved
into the buffer.
 But when everything is received i.e. the final one which causes the entire
buffer to be sent to the customer.
STREAMS
 Whereas stream will allow you to process the data as soon as it arrives from
the resource.
 In the below image each new chunk of data is received from the resource is
immediately provided to the consumer,
 thus consumer can process the data straightaway without waiting for all the
data to be collected in the buffer.
Stream Types
Types of
Streams
used for read
operation.
Readable
used for write
operation.
Writeable
used for both
read and write
operation.
Duplex
output is
computed
based on
input.
Transform
File System
 Node implements File I/O using simple wrappers around standard POSIX
functions.
 The Node File System (fs) module can be imported using the following
syntax
 File system is of 2 types (i) Synchronous (ii) Asynchronous
Synchronous:
 synchronous method never blocks a program during its execution, whereas
the second one does.
var fs = require("fs")
Asynchronous
 Asynchronous methods take the last parameter as the completion function
call-back and the first parameter of the call-back function as error.
 It is better to use an asynchronous method instead of a synchronous method
Scalable
 Node applications are highly
scalable
 Horizontal scaling of servers
 Adding more servers instead of
increasing the performance of
each
What is a Web Server?
 A Web Server is a software application which handles HTTP requests
 sent by the HTTP client, like web browsers, and returns web pages in
response to the clients.
 Web servers usually deliver html documents along with images, style sheets,
and scripts.
 Most of the web servers support server-side scripts
Web Application Architecture
 Client − This layer consists of web browsers, mobile browsers or
applications which can make HTTP requests to the web server.
 Server − This layer has the Web server which can intercept the requests
made by the clients and pass them the response.
 Business − This layer contains the application server which is utilized by the
web server to do the required processing. This layer interacts with the data
layer via the database or some external programs.
 Data − This layer contains the databases or any other source of data.
Who uses NodeJS
WHAT IS
Full-stack JavaScript
solution that helps you build
fast, robust and
maintainable production
web applicationsusing:
WHAT DOES ITM.E.A.N.?
express
WHY M.E.A.N.?
SAME LANGUAGE, SAMEOBJECTS.
{“_id”: ObjectId(“512638a28b799”),
“username” :“symonny” }
{“_id”: “512638a28b799”,
“username” :“symonny” }
{“_id”: “512638a28b799”,
“username” :“symonny” }
❖ NoSqL cross-platform document-oriented
database system
❖ JSON-like documents with dynamicschemas
❖ Easier & faster to send data between
❖ client and server (b/cdata saved in JSON format)
❖ Local Install:
➡MongoDB: http://www.mongodb.org/
❖ MongoDB-as-a-Service:
➡ Modulus:https://modulus.io
➡ Mongolab:https://mongolab.com
❖ A lightweight framework used to build single and
multi-page web applications inNode.JS
❖ Wrapper for the core Node.js HTTP
module objects.
❖ Provides functions for everything you may
need to build a modern webserver
❖ Learn More: http://expressjs.com
express
❖ Client-side MVC framework:http://angularjs.org
❖ Problem: Updating page withoutreload
Angular.js declarative, 2-way data❖ Solution:
binding
JavaScript platform built on V8❖ Server-side
engine
❖ Helps building highly scalable and concurrent
applications rapidly
❖ Makes multithreaded servereasy
❖ Event based concurrency
❖ Easy to modify and maintains apps, due
to piped modules
❖ Install fromhttp://nodejs.org
APPS SUITED FORNODE.JS
❖ E-Commerce
❖ Payment
Processing
❖ Social Media
❖ RealtimeServices
❖ MediaApplications
❖ Enterprise
Services

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Node.js Basics
Node.js Basics Node.js Basics
Node.js Basics
 
Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Node js for beginners
Node js for beginnersNode js for beginners
Node js for beginners
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
 
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 ...
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
 
Nodejs vatsal shah
Nodejs vatsal shahNodejs vatsal shah
Nodejs vatsal shah
 
How Node.js Works | Node.js Tutorial for Beginners
How Node.js Works | Node.js Tutorial for BeginnersHow Node.js Works | Node.js Tutorial for Beginners
How Node.js Works | Node.js Tutorial for Beginners
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
 
Node.Js: Basics Concepts and Introduction
Node.Js: Basics Concepts and Introduction Node.Js: Basics Concepts and Introduction
Node.Js: Basics Concepts and Introduction
 
Intro to Node.js (v1)
Intro to Node.js (v1)Intro to Node.js (v1)
Intro to Node.js (v1)
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS
 
Build RESTful API Using Express JS
Build RESTful API Using Express JSBuild RESTful API Using Express JS
Build RESTful API Using Express JS
 
Nodejs functions & modules
Nodejs functions & modulesNodejs functions & modules
Nodejs functions & modules
 
Node js
Node jsNode js
Node js
 
Use Node.js to create a REST API
Use Node.js to create a REST APIUse Node.js to create a REST API
Use Node.js to create a REST API
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express
 
Node js Introduction
Node js IntroductionNode js Introduction
Node js Introduction
 

Andere mochten auch

Asynchronous I/O in NodeJS - new standard or challenges?
Asynchronous I/O in NodeJS - new standard or challenges?Asynchronous I/O in NodeJS - new standard or challenges?
Asynchronous I/O in NodeJS - new standard or challenges?
Dinh Pham
 
NodeJS for Novices - 28/Oct/13 - Winnipeg, MB
NodeJS for Novices - 28/Oct/13 - Winnipeg, MBNodeJS for Novices - 28/Oct/13 - Winnipeg, MB
NodeJS for Novices - 28/Oct/13 - Winnipeg, MB
David Wesst
 
Efficient use of NodeJS
Efficient use of NodeJSEfficient use of NodeJS
Efficient use of NodeJS
Yura Bogdanov
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
Claudio Cicali
 

Andere mochten auch (20)

Nodejs Event Driven Concurrency for Web Applications
Nodejs Event Driven Concurrency for Web ApplicationsNodejs Event Driven Concurrency for Web Applications
Nodejs Event Driven Concurrency for Web Applications
 
Asynchronous I/O in NodeJS - new standard or challenges?
Asynchronous I/O in NodeJS - new standard or challenges?Asynchronous I/O in NodeJS - new standard or challenges?
Asynchronous I/O in NodeJS - new standard or challenges?
 
Alphorm.com Formation NodeJS, les fondamentaux
Alphorm.com Formation NodeJS, les fondamentauxAlphorm.com Formation NodeJS, les fondamentaux
Alphorm.com Formation NodeJS, les fondamentaux
 
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
 
Difference between-angular js-nodejs
Difference between-angular js-nodejsDifference between-angular js-nodejs
Difference between-angular js-nodejs
 
Javascript as a Platform
Javascript as a PlatformJavascript as a Platform
Javascript as a Platform
 
NodeJS: the good parts? A skeptic’s view (devnexus2014)
NodeJS: the good parts? A skeptic’s view (devnexus2014)NodeJS: the good parts? A skeptic’s view (devnexus2014)
NodeJS: the good parts? A skeptic’s view (devnexus2014)
 
NodeJS for Novices - 28/Oct/13 - Winnipeg, MB
NodeJS for Novices - 28/Oct/13 - Winnipeg, MBNodeJS for Novices - 28/Oct/13 - Winnipeg, MB
NodeJS for Novices - 28/Oct/13 - Winnipeg, MB
 
(C)NodeJS
(C)NodeJS(C)NodeJS
(C)NodeJS
 
Jaap : node, npm & grunt
Jaap : node, npm & gruntJaap : node, npm & grunt
Jaap : node, npm & grunt
 
Efficient use of NodeJS
Efficient use of NodeJSEfficient use of NodeJS
Efficient use of NodeJS
 
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
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
 
Node ppt
Node pptNode ppt
Node ppt
 
NodeJS: the good parts? A skeptic’s view (oredev, oredev2013)
NodeJS: the good parts? A skeptic’s view (oredev, oredev2013)NodeJS: the good parts? A skeptic’s view (oredev, oredev2013)
NodeJS: the good parts? A skeptic’s view (oredev, oredev2013)
 
Isomorphic web application
Isomorphic web applicationIsomorphic web application
Isomorphic web application
 
Building Web Apps & APIs With Node JS
Building Web Apps & APIs With Node JSBuilding Web Apps & APIs With Node JS
Building Web Apps & APIs With Node JS
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
 
NodeJS
NodeJSNodeJS
NodeJS
 
5 Ways to use Node in the Network
5 Ways to use Node in the Network5 Ways to use Node in the Network
5 Ways to use Node in the Network
 

Ähnlich wie NodeJS guide for beginners

Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
Rob Davarnia
 
Node Js Non-blocking or asynchronous Blocking or synchronous.pdf
Node Js Non-blocking or asynchronous  Blocking or synchronous.pdfNode Js Non-blocking or asynchronous  Blocking or synchronous.pdf
Node Js Non-blocking or asynchronous Blocking or synchronous.pdf
DarshanaMallick
 

Ähnlich wie NodeJS guide for beginners (20)

Proposal
ProposalProposal
Proposal
 
Node js
Node jsNode js
Node js
 
Building Applications With the MEAN Stack
Building Applications With the MEAN StackBuilding Applications With the MEAN Stack
Building Applications With the MEAN Stack
 
Nodejs intro
Nodejs introNodejs intro
Nodejs intro
 
Node Session - 1
Node Session - 1Node Session - 1
Node Session - 1
 
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
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect GuideKalp Corporate Node JS Perfect Guide
Kalp Corporate Node JS Perfect Guide
 
Best node js course
Best node js courseBest node js course
Best node js course
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
 
Introduction to Node.JS
Introduction to Node.JSIntroduction to Node.JS
Introduction to Node.JS
 
Top 30 Node.js interview questions
Top 30 Node.js interview questionsTop 30 Node.js interview questions
Top 30 Node.js interview questions
 
Nodejs
NodejsNodejs
Nodejs
 
Nodejs
NodejsNodejs
Nodejs
 
NodeJS @ ACS
NodeJS @ ACSNodeJS @ ACS
NodeJS @ ACS
 
Node js beginner
Node js beginnerNode js beginner
Node js beginner
 
Node js meetup
Node js meetupNode js meetup
Node js meetup
 
Node Js Non-blocking or asynchronous Blocking or synchronous.pdf
Node Js Non-blocking or asynchronous  Blocking or synchronous.pdfNode Js Non-blocking or asynchronous  Blocking or synchronous.pdf
Node Js Non-blocking or asynchronous Blocking or synchronous.pdf
 
NodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin WayNodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin Way
 
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
 

Kürzlich hochgeladen

Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Kürzlich hochgeladen (20)

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 

NodeJS guide for beginners

  • 2. What’s I/O?  Distance of data travel from input to output.
  • 3. What is JavaScript ?  It is dynamic programming language.  It is client side script to interact with user.  It most commonly used as a part of web browser
  • 4. Background  Node.js was invented in 2009 by Ryan Dahl  inspired to create Node.js after seeing a file upload progress bar on FLICKR  Open source , sponsored by Joyent and Microsoft  Ryan was a mathematics student and dropped out of college.  Node.js runs on V8.
  • 5. Introduction: Basic What is NodeJS ?  NodeJS is an open source , cross platform runtime environment for server side and networking application.  It is written in JavaScript and can run on Linux , Mac , Windows , FreeBSD.  It provided an event driven architecture and a non blocking I/O that optimize and scalability. These technology uses for real time application.  It used Google JavaScript V8 Engine to Execute Code.
  • 6. JavaScript V8 Engine  The V8 JavaScript Engine is an open source JavaScript engine developed by Google for the Google Chrome web browser.  V8 compiles JavaScript to native machine code (IA-32, x86-64, ARM, or MIPS ISAs) before executing it.  V8 can run standalone, or can be embedded into any C++ application
  • 7. Why Use NodeJS?  Node's goal is to provide an easy way to build scalable network programs. What is unique about NodeJS?  Using JavaScript on server-side making communication between client and server will happen in same language.  Servers are Event based serves each request in Evented Loop. So, it can handle simultaneous requests.
  • 8. Reasons touse NodeJS  It is very lightweight and fast. There has been over 200,000 visits on this website in three weeks and minimal server resources has been able to handle it all.  The counter is really easy to make to be real time.  Node.js was easy to configure.  There are lots of modules available for free.  NodeJS work with NoSQL as well.
  • 9. When not use NodeJS  Your server request is dependent on heavy CPU consuming algorithm/Job. NodeJS Setup  Download at http://nodejs.org  Set Environment variable (Last version automatic set)  Open command line and type following. node -v
  • 10. What is Callback?  Call-back is an asynchronous equivalent for a function.  A call-back function is called at the completion of a given task.  Node makes heavy use of call-backs.
  • 11. Blocking I/O:  Traditional applications waits for a set code to complete before it displays the content. This is called blocking code.
  • 12. Non blocking I/O:  In non blocking Once the request is made we continue on to the next line of code before waiting for the time consuming request to finish.  Uses callback functions to handle non blocking code.
  • 13. What makes node better? Event driven • Just like java script events on the client, Node can handle various events on the server • Examples of server events are file transfer , request for a page , loading content from database
  • 15. REPL Terminal Read − Reads user's input, parses the input into JavaScript data-structure, and stores in memory. Eval − Takes and evaluates the data structure. Print − Prints the result. Loop − Loops the above command until the user presses ctrl-c twice. Starting REPL Simple Expression node > node > 1 + 3 4 >1 + ( 2 * 3 ) - 4 3 >
  • 16. REPL Commands ctrl + c − terminate the current command. ctrl + c twice − terminate the Node REPL. ctrl + d − terminate the Node REPL. Up/Down Keys − see command history and modify previous commands. tab Keys − list of current commands. .help − list of all commands. .break − exit from multiline expression. .clear − exit from multiline expression. .save filename − save the current Node REPL session to a file. .load filename − load file content in current Node REPL session.
  • 17. What is npm? NPM Easy for developers to share and reuse code Makes it easy to update the code that you’re sharing
  • 19. The npm comes bundled with Node.js installables in versions after that v0.6.3. You can check the version by command. npm –v (or) npm version
  • 20. Installing Modules using npm Following is the syntax to install any Node.js module: For example: npm install <Module Name> npm install express
  • 21. Local Installation Global Installation • Local Mode Package installation • Node module accessible • require() command • Npm ls • Global Mode Package installation • System Directory Not- accessible • Require() command • Npm ls - g CLI
  • 22. Uninstalling a Module npm uninstall express Updating a Module npm update express Search a Module npm search express
  • 23. BUFFER  For an input operation, buffer mode will wait until all the data is collected into a buffer  and then pass it to a call-back as soon as the entire resource is read.  In the below image you can see that when some data are received it is saved into the buffer.  But when everything is received i.e. the final one which causes the entire buffer to be sent to the customer.
  • 24. STREAMS  Whereas stream will allow you to process the data as soon as it arrives from the resource.  In the below image each new chunk of data is received from the resource is immediately provided to the consumer,  thus consumer can process the data straightaway without waiting for all the data to be collected in the buffer.
  • 25. Stream Types Types of Streams used for read operation. Readable used for write operation. Writeable used for both read and write operation. Duplex output is computed based on input. Transform
  • 26. File System  Node implements File I/O using simple wrappers around standard POSIX functions.  The Node File System (fs) module can be imported using the following syntax  File system is of 2 types (i) Synchronous (ii) Asynchronous Synchronous:  synchronous method never blocks a program during its execution, whereas the second one does. var fs = require("fs")
  • 27. Asynchronous  Asynchronous methods take the last parameter as the completion function call-back and the first parameter of the call-back function as error.  It is better to use an asynchronous method instead of a synchronous method
  • 28. Scalable  Node applications are highly scalable  Horizontal scaling of servers  Adding more servers instead of increasing the performance of each
  • 29. What is a Web Server?  A Web Server is a software application which handles HTTP requests  sent by the HTTP client, like web browsers, and returns web pages in response to the clients.  Web servers usually deliver html documents along with images, style sheets, and scripts.  Most of the web servers support server-side scripts
  • 30. Web Application Architecture  Client − This layer consists of web browsers, mobile browsers or applications which can make HTTP requests to the web server.  Server − This layer has the Web server which can intercept the requests made by the clients and pass them the response.  Business − This layer contains the application server which is utilized by the web server to do the required processing. This layer interacts with the data layer via the database or some external programs.  Data − This layer contains the databases or any other source of data.
  • 31.
  • 34. Full-stack JavaScript solution that helps you build fast, robust and maintainable production web applicationsusing: WHAT DOES ITM.E.A.N.? express
  • 35.
  • 36. WHY M.E.A.N.? SAME LANGUAGE, SAMEOBJECTS. {“_id”: ObjectId(“512638a28b799”), “username” :“symonny” } {“_id”: “512638a28b799”, “username” :“symonny” } {“_id”: “512638a28b799”, “username” :“symonny” }
  • 37. ❖ NoSqL cross-platform document-oriented database system ❖ JSON-like documents with dynamicschemas ❖ Easier & faster to send data between ❖ client and server (b/cdata saved in JSON format) ❖ Local Install: ➡MongoDB: http://www.mongodb.org/ ❖ MongoDB-as-a-Service: ➡ Modulus:https://modulus.io ➡ Mongolab:https://mongolab.com
  • 38. ❖ A lightweight framework used to build single and multi-page web applications inNode.JS ❖ Wrapper for the core Node.js HTTP module objects. ❖ Provides functions for everything you may need to build a modern webserver ❖ Learn More: http://expressjs.com express
  • 39. ❖ Client-side MVC framework:http://angularjs.org ❖ Problem: Updating page withoutreload Angular.js declarative, 2-way data❖ Solution: binding
  • 40. JavaScript platform built on V8❖ Server-side engine ❖ Helps building highly scalable and concurrent applications rapidly ❖ Makes multithreaded servereasy ❖ Event based concurrency ❖ Easy to modify and maintains apps, due to piped modules ❖ Install fromhttp://nodejs.org
  • 41. APPS SUITED FORNODE.JS ❖ E-Commerce ❖ Payment Processing ❖ Social Media ❖ RealtimeServices ❖ MediaApplications ❖ Enterprise Services