SlideShare uma empresa Scribd logo
1 de 33
Baixar para ler offline
Covering
● What is Node
● What makes Node
● What is NPM
● Why all this?
...
Hands on!
● Node.js: Hello world (cli & web)
● Express.js: Hello world
● Sails.js: Hello world
● Build a Rest API
● Test the API
● Use the API
What is Node?
Node.js® is a platform built on
Chrome's JavaScript runtime for:
● easily building fast,
● scalable network applications.
Node.js uses an:
● event-driven,
● non-blocking I/O model
that makes it lightweight and efficient, perfect for
data-intensive real-time applications that run
across distributed devices.
What is Node?
Node.js® is a platform built on
Chrome's JavaScript runtime for:
● easily building fast,
● scalable network applications.
Node.js uses an:
● event-driven,
● non-blocking I/O model
that makes it lightweight and efficient, perfect for
data-intensive real-time applications that run
across distributed devices.
It's all about non-blocking,
asynchronous architecture
What is Node?
Node.js® is a platform built on
Chrome's JavaScript runtime for:
● easily building fast,
● scalable network applications.
Node.js uses an:
● event-driven,
● non-blocking I/O model
that makes it lightweight and efficient, perfect for
data-intensive real-time applications that run
across distributed devices.
It's all about non-blocking,
asynchronous architecture
This means any activity taking
a long time to finish, such as
file access, network requests,
and database operations, are
requested and put aside until the
results are ready and returned
What is Node?
Node.js® is a platform built on
Chrome's JavaScript runtime for:
● easily building fast,
● scalable network applications.
Node.js uses an:
● event-driven,
● non-blocking I/O model
that makes it lightweight and efficient, perfect for
data-intensive real-time applications that run
across distributed devices.
Easy setup & code
What is Node?
Node.js® is a platform built on
Chrome's JavaScript runtime for:
● easily building fast,
● scalable network applications.
Node.js uses an:
● event-driven,
● non-blocking I/O model
that makes it lightweight and efficient, perfect for
data-intensive real-time applications that run
across distributed devices.
It is the server!
What is Node?
Node.js® is a platform built on
Chrome's JavaScript runtime for:
● easily building fast,
● scalable network applications.
Node.js uses an:
● event-driven,
● non-blocking I/O model
that makes it lightweight and efficient, perfect for
data-intensive real-time applications that run
across distributed devices.
It is the server!
What is Node?
Node.js® is a platform built on
Chrome's JavaScript runtime for:
● easily building fast,
● scalable network applications.
Node.js uses an:
● event-driven,
● non-blocking I/O model
that makes it lightweight and efficient, perfect for
data-intensive real-time applications that run
across distributed devices.
It is the server!
What is Node?
Node.js® is a platform built on
Chrome's JavaScript runtime for:
● easily building fast,
● scalable network applications.
Node.js uses an:
● event-driven,
● non-blocking I/O model
that makes it lightweight and efficient, perfect for
data-intensive real-time applications that run
across distributed devices.
It is the server!
What is Node?
Node.js® is a platform built on
Chrome's JavaScript runtime for:
● easily building fast,
● scalable network applications.
Node.js uses an:
● event-driven,
● non-blocking I/O model
that makes it lightweight and efficient, perfect for
data-intensive real-time applications that run
across distributed devices.
It is the server!
What is Node?
Node.js® is a platform built on
Chrome's JavaScript runtime for:
● easily building fast,
● scalable network applications.
Node.js uses an:
● event-driven,
● non-blocking I/O model
that makes it lightweight and efficient, perfect for
data-intensive real-time applications that run
across distributed devices.
It is the server!
What is Node?
Node.js® is a platform built on
Chrome's JavaScript runtime for:
● easily building fast,
● scalable network applications.
Node.js uses an:
● event-driven,
● non-blocking I/O model
that makes it lightweight and efficient, perfect for
data-intensive real-time applications that run
across distributed devices.
It is the server!
Just 1
What is Node?
Node.js® is a platform built on
Chrome's JavaScript runtime for:
● easily building fast,
● scalable network applications.
Node.js uses an:
● event-driven,
● non-blocking I/O model
that makes it lightweight and efficient, perfect for
data-intensive real-time applications that run
across distributed devices.
It is the server!
Just 1
But if your app crashs it
will bring down the server
What is Node?
Node.js® is a platform built on
Chrome's JavaScript runtime for:
● easily building fast,
● scalable network applications.
Node.js uses an:
● event-driven,
● non-blocking I/O model
that makes it lightweight and efficient, perfect for
data-intensive real-time applications that run
across distributed devices.
No polling..
just callbacks
= FAST but out of order
What is Node?
Node.js® is a platform built on
Chrome's JavaScript runtime for:
● easily building fast,
● scalable network applications.
Node.js uses an:
● event-driven,
● non-blocking I/O model
that makes it lightweight and efficient, perfect for
data-intensive real-time applications that run
across distributed devices.
No headaches with
multithreaded async I/O
Non-blocking / Asynchronous
What is
Node page manager
What is
Node page manager
NPM is a package manager for JavaScript, and is
installed by default for Node.js.
What is
Node page manager
NPM is a package manager for JavaScript, and is
installed by default for Node.js.
NPM runs through the command line and manages
dependencies for an application.
What is
Node page manager
NPM is a package manager for JavaScript, and is
installed by default for Node.js.
NPM runs through the command line and manages
dependencies for an application.
What is
Node page manager
NPM is a package manager for JavaScript, and is
installed by default for Node.js.
NPM runs through the command line and manages
dependencies for an application.
It also allows users to install Node.js applications
that are available on the npm registry.
And because of JavaScript
Mongo DB
Hand on TIME!
Installing
Mac: brew install node⎆
Linux: apt-get install nodejs⎆
Linux: apt-get install npm⎆
⎆ node -v
⎆ npm -v
Server App
⎆ Node
⎆ Console.log(“Hi”)
✎
var http = require("http");
var url = require("url");
var start = function() {
var onRequest = function(request, response) {
var pathname = url.parse(request.url).pathname;
console.log("Request for " + pathname);
response.writeHead(200, {
"Content-Type": "text/plain"
});
response.write("HackerShip");
return response.end();
};
http.createServer(onRequest).listen(8888);
return console.log("Server has started.");
};
start();
⎙ balbal.js
⎆ node balbal.js
Node is the Server..
Not a framework!
✎
var http = require("http");
var url = require("url");
var start = function() {
var onRequest = function(request, response) {
var pathname = url.parse(request.url).pathname;
console.log("Request for " + pathname);
response.writeHead(200, {
"Content-Type": "text/plain"
});
response.write("HackerShip");
return response.end();
};
http.createServer(onRequest).listen(8888);
return console.log("Server has started.");
};
start();
⎙ balbal.js
⎆ node balbal.js
Installing & Run
⎆ npm install -g express
⎆ express HS
⎆ cd HS
⎆ npm install
⎆ npm start
☺ http://localhost:3000/
HSroutesindex.js ✍
Installing & Run
⎆ npm install -g sails
⎆ sails new HS2
⎆ cd HS2
⎆ sails lift
☺ http://localhost:1337/
Auto-generate REST APIs
⎆ sails generate api messages
api/models/ … api/controllers/
www.getpostman.com
⎆ sails lift
Using REST APIs [HTML]
<form action="http://localhost:1337/messages" method="post">
Text: <input type="text" name="text"><br>
<input type="submit" value="Submit">
</form>
<script src="http://code.jquery.com/jquery-2.1.3.js"></script>
<script>
// ...
</script>
Using REST APIs [JS]
var myJSONData = '{"text":”some text”}';
$.ajax({type: 'POST',
url: 'http://localhost:1337/messages',
data: myJSONData,
success: function(data) {
alert("POSTED SUCCESSFULLY TO THE SERVER");
}, // Success Function
error: function(err){
alert(err.message);
}
}); // Ajax Call

Mais conteúdo relacionado

Mais procurados

Nodejs getting started
Nodejs getting startedNodejs getting started
Nodejs getting startedTriet Ho
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in ReactTalentica Software
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jibanJibanananda Sana
 
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
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentIrfan Maulana
 
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsYakov Fain
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJSJITENDRA KUMAR PATEL
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in Nodejs Irfan Maulana
 
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
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express jsAhmed Assaf
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationAndrew Rota
 
MEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopMEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopValeri Karpov
 
Back to the future: Isomorphic javascript applications
Back to the future:  Isomorphic javascript applicationsBack to the future:  Isomorphic javascript applications
Back to the future: Isomorphic javascript applicationsLuciano Colosio
 
Understand How Node.js and Core Features Works
Understand How Node.js and Core Features WorksUnderstand How Node.js and Core Features Works
Understand How Node.js and Core Features WorksHengki Sihombing
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN StackTroy Miles
 

Mais procurados (20)

Nodejs getting started
Nodejs getting startedNodejs getting started
Nodejs getting started
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 
Node js Introduction
Node js IntroductionNode js Introduction
Node js Introduction
 
Best node js course
Best node js courseBest node js course
Best node js course
 
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
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
 
Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot apps
 
Getting started with node.js
Getting started with node.jsGetting started with node.js
Getting started with node.js
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 
Create Rest API in Nodejs
Create Rest API in Nodejs Create Rest API in Nodejs
Create Rest API in 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
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express js
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Integrating React.js Into a PHP Application
Integrating React.js Into a PHP ApplicationIntegrating React.js Into a PHP Application
Integrating React.js Into a PHP Application
 
MEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona WorkshopMEAN Stack WeNode Barcelona Workshop
MEAN Stack WeNode Barcelona Workshop
 
Back to the future: Isomorphic javascript applications
Back to the future:  Isomorphic javascript applicationsBack to the future:  Isomorphic javascript applications
Back to the future: Isomorphic javascript applications
 
Why NodeJS
Why NodeJSWhy NodeJS
Why NodeJS
 
Understand How Node.js and Core Features Works
Understand How Node.js and Core Features WorksUnderstand How Node.js and Core Features Works
Understand How Node.js and Core Features Works
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
 

Semelhante a Node, express & sails

Quick introduction to nodeJs
Quick introduction to nodeJsQuick introduction to nodeJs
Quick introduction to nodeJsAram Rafeq
 
Difference between Node.js vs Java script
Difference between Node.js vs Java scriptDifference between Node.js vs Java script
Difference between Node.js vs Java scriptGhulamHussain799241
 
An Introduction to Node.js Development with Windows Azure
An Introduction to Node.js Development with Windows AzureAn Introduction to Node.js Development with Windows Azure
An Introduction to Node.js Development with Windows AzureTroy Miles
 
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
 
Node js Development Company - Aparajayah
Node js Development Company - AparajayahNode js Development Company - Aparajayah
Node js Development Company - AparajayahAparajayahTechnologi
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?Balajihope
 
8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx
8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx
8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx75waytechnologies
 
Node.js In The Enterprise - A Primer
Node.js In The Enterprise - A PrimerNode.js In The Enterprise - A Primer
Node.js In The Enterprise - A PrimerNaveen S.R
 
An overview of node.js
An overview of node.jsAn overview of node.js
An overview of node.jsvaluebound
 
Node.js and Enterprise Web Apps: Know all About it
Node.js and Enterprise Web Apps: Know all About itNode.js and Enterprise Web Apps: Know all About it
Node.js and Enterprise Web Apps: Know all About itFibonalabs
 
Understanding Node.js and Django.docx
Understanding Node.js and Django.docxUnderstanding Node.js and Django.docx
Understanding Node.js and Django.docxSavior_Marketing
 

Semelhante a Node, express & sails (20)

Quick introduction to nodeJs
Quick introduction to nodeJsQuick introduction to nodeJs
Quick introduction to nodeJs
 
NodeJS and what is actually does
NodeJS and what is actually doesNodeJS and what is actually does
NodeJS and what is actually does
 
02 Node introduction
02 Node introduction02 Node introduction
02 Node introduction
 
Node.js.pdf
Node.js.pdfNode.js.pdf
Node.js.pdf
 
Difference between Node.js vs Java script
Difference between Node.js vs Java scriptDifference between Node.js vs Java script
Difference between Node.js vs Java script
 
Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
 
Nodejs
NodejsNodejs
Nodejs
 
An Introduction to Node.js Development with Windows Azure
An Introduction to Node.js Development with Windows AzureAn Introduction to Node.js Development with Windows Azure
An Introduction to Node.js Development with Windows Azure
 
Node js
Node jsNode js
Node js
 
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
 
Node js Development Company - Aparajayah
Node js Development Company - AparajayahNode js Development Company - Aparajayah
Node js Development Company - Aparajayah
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
What is node.js
What is node.jsWhat is node.js
What is node.js
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
 
8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx
8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx
8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx
 
Node.js In The Enterprise - A Primer
Node.js In The Enterprise - A PrimerNode.js In The Enterprise - A Primer
Node.js In The Enterprise - A Primer
 
An overview of node.js
An overview of node.jsAn overview of node.js
An overview of node.js
 
Node.js and Enterprise Web Apps: Know all About it
Node.js and Enterprise Web Apps: Know all About itNode.js and Enterprise Web Apps: Know all About it
Node.js and Enterprise Web Apps: Know all About it
 
Understanding Node.js and Django.docx
Understanding Node.js and Django.docxUnderstanding Node.js and Django.docx
Understanding Node.js and Django.docx
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 

Mais de Brian Shannon

Mais de Brian Shannon (6)

Go live or go home
Go live or go homeGo live or go home
Go live or go home
 
Leadership tip
Leadership tipLeadership tip
Leadership tip
 
Product tips
Product tipsProduct tips
Product tips
 
Coder tips
Coder tipsCoder tips
Coder tips
 
Founder tips
Founder tipsFounder tips
Founder tips
 
Processing
ProcessingProcessing
Processing
 

Último

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 

Último (20)

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 

Node, express & sails

  • 1.
  • 2. Covering ● What is Node ● What makes Node ● What is NPM ● Why all this? ...
  • 3. Hands on! ● Node.js: Hello world (cli & web) ● Express.js: Hello world ● Sails.js: Hello world ● Build a Rest API ● Test the API ● Use the API
  • 4. What is Node? Node.js® is a platform built on Chrome's JavaScript runtime for: ● easily building fast, ● scalable network applications. Node.js uses an: ● event-driven, ● non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
  • 5. What is Node? Node.js® is a platform built on Chrome's JavaScript runtime for: ● easily building fast, ● scalable network applications. Node.js uses an: ● event-driven, ● non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. It's all about non-blocking, asynchronous architecture
  • 6. What is Node? Node.js® is a platform built on Chrome's JavaScript runtime for: ● easily building fast, ● scalable network applications. Node.js uses an: ● event-driven, ● non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. It's all about non-blocking, asynchronous architecture This means any activity taking a long time to finish, such as file access, network requests, and database operations, are requested and put aside until the results are ready and returned
  • 7. What is Node? Node.js® is a platform built on Chrome's JavaScript runtime for: ● easily building fast, ● scalable network applications. Node.js uses an: ● event-driven, ● non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. Easy setup & code
  • 8. What is Node? Node.js® is a platform built on Chrome's JavaScript runtime for: ● easily building fast, ● scalable network applications. Node.js uses an: ● event-driven, ● non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. It is the server!
  • 9. What is Node? Node.js® is a platform built on Chrome's JavaScript runtime for: ● easily building fast, ● scalable network applications. Node.js uses an: ● event-driven, ● non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. It is the server!
  • 10. What is Node? Node.js® is a platform built on Chrome's JavaScript runtime for: ● easily building fast, ● scalable network applications. Node.js uses an: ● event-driven, ● non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. It is the server!
  • 11. What is Node? Node.js® is a platform built on Chrome's JavaScript runtime for: ● easily building fast, ● scalable network applications. Node.js uses an: ● event-driven, ● non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. It is the server!
  • 12. What is Node? Node.js® is a platform built on Chrome's JavaScript runtime for: ● easily building fast, ● scalable network applications. Node.js uses an: ● event-driven, ● non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. It is the server!
  • 13. What is Node? Node.js® is a platform built on Chrome's JavaScript runtime for: ● easily building fast, ● scalable network applications. Node.js uses an: ● event-driven, ● non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. It is the server!
  • 14. What is Node? Node.js® is a platform built on Chrome's JavaScript runtime for: ● easily building fast, ● scalable network applications. Node.js uses an: ● event-driven, ● non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. It is the server! Just 1
  • 15. What is Node? Node.js® is a platform built on Chrome's JavaScript runtime for: ● easily building fast, ● scalable network applications. Node.js uses an: ● event-driven, ● non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. It is the server! Just 1 But if your app crashs it will bring down the server
  • 16. What is Node? Node.js® is a platform built on Chrome's JavaScript runtime for: ● easily building fast, ● scalable network applications. Node.js uses an: ● event-driven, ● non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. No polling.. just callbacks = FAST but out of order
  • 17. What is Node? Node.js® is a platform built on Chrome's JavaScript runtime for: ● easily building fast, ● scalable network applications. Node.js uses an: ● event-driven, ● non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. No headaches with multithreaded async I/O
  • 19. What is Node page manager
  • 20. What is Node page manager NPM is a package manager for JavaScript, and is installed by default for Node.js.
  • 21. What is Node page manager NPM is a package manager for JavaScript, and is installed by default for Node.js. NPM runs through the command line and manages dependencies for an application.
  • 22. What is Node page manager NPM is a package manager for JavaScript, and is installed by default for Node.js. NPM runs through the command line and manages dependencies for an application.
  • 23. What is Node page manager NPM is a package manager for JavaScript, and is installed by default for Node.js. NPM runs through the command line and manages dependencies for an application. It also allows users to install Node.js applications that are available on the npm registry.
  • 24. And because of JavaScript Mongo DB
  • 26. Installing Mac: brew install node⎆ Linux: apt-get install nodejs⎆ Linux: apt-get install npm⎆ ⎆ node -v ⎆ npm -v Server App ⎆ Node ⎆ Console.log(“Hi”)
  • 27. ✎ var http = require("http"); var url = require("url"); var start = function() { var onRequest = function(request, response) { var pathname = url.parse(request.url).pathname; console.log("Request for " + pathname); response.writeHead(200, { "Content-Type": "text/plain" }); response.write("HackerShip"); return response.end(); }; http.createServer(onRequest).listen(8888); return console.log("Server has started."); }; start(); ⎙ balbal.js ⎆ node balbal.js Node is the Server.. Not a framework!
  • 28. ✎ var http = require("http"); var url = require("url"); var start = function() { var onRequest = function(request, response) { var pathname = url.parse(request.url).pathname; console.log("Request for " + pathname); response.writeHead(200, { "Content-Type": "text/plain" }); response.write("HackerShip"); return response.end(); }; http.createServer(onRequest).listen(8888); return console.log("Server has started."); }; start(); ⎙ balbal.js ⎆ node balbal.js
  • 29. Installing & Run ⎆ npm install -g express ⎆ express HS ⎆ cd HS ⎆ npm install ⎆ npm start ☺ http://localhost:3000/ HSroutesindex.js ✍
  • 30. Installing & Run ⎆ npm install -g sails ⎆ sails new HS2 ⎆ cd HS2 ⎆ sails lift ☺ http://localhost:1337/
  • 31. Auto-generate REST APIs ⎆ sails generate api messages api/models/ … api/controllers/ www.getpostman.com ⎆ sails lift
  • 32. Using REST APIs [HTML] <form action="http://localhost:1337/messages" method="post"> Text: <input type="text" name="text"><br> <input type="submit" value="Submit"> </form> <script src="http://code.jquery.com/jquery-2.1.3.js"></script> <script> // ... </script>
  • 33. Using REST APIs [JS] var myJSONData = '{"text":”some text”}'; $.ajax({type: 'POST', url: 'http://localhost:1337/messages', data: myJSONData, success: function(data) { alert("POSTED SUCCESSFULLY TO THE SERVER"); }, // Success Function error: function(err){ alert(err.message); } }); // Ajax Call