SlideShare a Scribd company logo
Node.js
Atul Jain
Naman Gupta
what is javascript?
nothing to do with java
a complete language
moving parts of a web
page
not just window.open()
nodejs
And then came Node.js.
JavaScript on the server,
how cool is that?
Node.js is a JavaScript
runtime built on Chrome's
V8 JavaScript engine.
Node.js uses an event-
driven, non-blocking I/O
model.
nodejs
Node.js is really two things:
a runtime environment and
a library
why nodejs?
much easier to setup and faster to code a web app in node.js than any other
MVC (models, views, controllers) framework (say, django, flask etc).
great for single page apps
Odyssey 15 website was hosted on a five lines of code server. WUT? :O
node.js is faster, (HELL YEAH!)
node in ONE loc (ONE LINE TO RULE THEM ALL)
server.js
-------------------------------------------------------------------
console.log(“Hello, Byld”);
terminal
---------------------------------------------------------------
----
$ node server.js
Hello, Byld
$
event driven
event loop: listens for events and calls a callback function once an event has been
detected
single thread
event-driven programming is application flow control that is determined by events
or changes in state.
non blocking code (for real)
var result = database.query("SELECT * FROM hugetable");
console.log("Hello World");
event-driven, asynchronous callbacks, by utilizing an event loop.
non blocking code (for real)
var result = database.query("SELECT * FROM hugetable");
console.log("Hello World");
event-driven, asynchronous callbacks, by utilizing an event loop.
database.query("SELECT * FROM hugetable", function (rows) {
var result = rows;
});
console.log("Hello World");
npm
Node.js' package
ecosystem, npm, is the
largest ecosystem of open
source libraries in the
world.
dependency tree
Ok, this stuff is boring, right?
Let’s write some real stuff.
We will now create a web application serving a
basic purpose of “file-uploading”
What will our application do?
1. The user should be able to use our web-app on their browser.
2. The user should see a welcome page on http://localhost:3000/go
3. On the above web-page, there should be a file-upload form which accepts
image files
4. On submitting the form, the user will be redirected to
http://localhost:3000/upload where user will see the uploaded image
what do we need for this?
1. To server HTTP requests - A HTTP server.
2. Our server will answer differently to requests, depending on the URL we
need some kind of router which maps requests to request /handlers.
3. We need request handlers once the server has successfully routed a URL
request.
a. This request handler should be able to handle the POST data coming through static HTML
page from our website
b. We have to store the image temporarily on the server storage and show it in the /upload.
4. Once the requested URL is routed to proper route and the incoming data is
retrieved from that request, we will show that image on next URL (‘/upload’)
let the coding begin
file upload
middlewares
app.use()
listens to the requests and runs some code selectively
example express.static
node.js is funny
https://medium.com/@c2c/nodejs-a-
quick-optimization-advice-7353b820c92e
thanks

More Related Content

What's hot (20)

PDF
The Evolution of Airbnb's Frontend
Spike Brehm
 
PDF
Node, express & sails
Brian Shannon
 
PPTX
Cache for community edition
irfan1008
 
PDF
Building Isomorphic Apps (JSConf.Asia 2014)
Spike Brehm
 
ODP
WordPress as a Platform - talk to Bristol Open Source Meetup, 2014-12-08
Tim Stephenson
 
PDF
Isomorphic React Applications: Performance And Scalability
Denis Izmaylov
 
PPTX
Building isomorphic java script apps faster with next.js
Madhav Chaturvedi
 
PPTX
Module design pattern i.e. express js
Ahmed Assaf
 
PPTX
Caching and invalidating with managed store
irfan1008
 
PDF
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...
Valeri Karpov
 
PPT
Node.js Express Framework
TheCreativedev Blog
 
PDF
Grokking #9: Building a real-time and offline editing service with Couchbase
Oliver N
 
PDF
Sails.js Intro
Nicholas Jansma
 
PDF
JSConf US 2014: Building Isomorphic Apps
Spike Brehm
 
PDF
Server rendering-talk
Daiwei Lu
 
PDF
Isomorphic JavaScript with Nashorn
Maxime Najim
 
PPT
Active Server Page(ASP)
Keshab Nath
 
PDF
Be Happy With Ruby on Rails - Ecosystem
Lucas Renan
 
ODP
A Toda Maquina Con Ruby on Rails
Rafael García
 
PPT
HTML5 Multithreading
Allan Huang
 
The Evolution of Airbnb's Frontend
Spike Brehm
 
Node, express & sails
Brian Shannon
 
Cache for community edition
irfan1008
 
Building Isomorphic Apps (JSConf.Asia 2014)
Spike Brehm
 
WordPress as a Platform - talk to Bristol Open Source Meetup, 2014-12-08
Tim Stephenson
 
Isomorphic React Applications: Performance And Scalability
Denis Izmaylov
 
Building isomorphic java script apps faster with next.js
Madhav Chaturvedi
 
Module design pattern i.e. express js
Ahmed Assaf
 
Caching and invalidating with managed store
irfan1008
 
MEAN Stack NYC Meetup 20150717: TDD Your AngularJS + Ionic Directives With jQ...
Valeri Karpov
 
Node.js Express Framework
TheCreativedev Blog
 
Grokking #9: Building a real-time and offline editing service with Couchbase
Oliver N
 
Sails.js Intro
Nicholas Jansma
 
JSConf US 2014: Building Isomorphic Apps
Spike Brehm
 
Server rendering-talk
Daiwei Lu
 
Isomorphic JavaScript with Nashorn
Maxime Najim
 
Active Server Page(ASP)
Keshab Nath
 
Be Happy With Ruby on Rails - Ecosystem
Lucas Renan
 
A Toda Maquina Con Ruby on Rails
Rafael García
 
HTML5 Multithreading
Allan Huang
 

Viewers also liked (11)

PPTX
Sai neelkanth engineers
Vinod Mishra
 
PPTX
Saineelkanth engineers
Vinod Mishra
 
PDF
Thomas2015_EvdenceSummary_EN
Emily Sully
 
PDF
SCANDLINES PROFILE 08 2015
JIJITH KUMAR [JACK]
 
PDF
Andrew Gannon CV Edited copy 2
Andrew Gannon
 
PDF
SAI NEELKANTH ENGINEERS BROUCHER
Vinod Mishra
 
PPTX
Human rights
gyanu poudel
 
PDF
Email Security Threats: IT Manager's Eyes Only
Topsec Technology
 
PDF
THE RISING TIDE--
Nick Cambden
 
PDF
CURRICULUM - RESHMA MAHARAJ (9-2016)
Reshma Maharaj
 
PDF
Inspiring Sustainability
Nick Cambden
 
Sai neelkanth engineers
Vinod Mishra
 
Saineelkanth engineers
Vinod Mishra
 
Thomas2015_EvdenceSummary_EN
Emily Sully
 
SCANDLINES PROFILE 08 2015
JIJITH KUMAR [JACK]
 
Andrew Gannon CV Edited copy 2
Andrew Gannon
 
SAI NEELKANTH ENGINEERS BROUCHER
Vinod Mishra
 
Human rights
gyanu poudel
 
Email Security Threats: IT Manager's Eyes Only
Topsec Technology
 
THE RISING TIDE--
Nick Cambden
 
CURRICULUM - RESHMA MAHARAJ (9-2016)
Reshma Maharaj
 
Inspiring Sustainability
Nick Cambden
 
Ad

Similar to Web with Nodejs (20)

PPTX
Server side programming
javed ahmed
 
DOCX
Node js getting started
Pallavi Srivastava
 
ODP
An Overview of Node.js
Ayush Mishra
 
PDF
SocketStream
Paul Jensen
 
DOCX
server side rendering with angular JS.docx
React Masters
 
PPTX
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
KEY
Architecting single-page front-end apps
Zohar Arad
 
PDF
NodeJS @ ACS
Mauro Parra-Miranda
 
PDF
AngularJS with Slim PHP Micro Framework
Backand Cohen
 
PDF
Integrating React.js Into a PHP Application: Dutch PHP 2019
Andrew Rota
 
PDF
React loadable
George Bukhanov
 
PPTX
Dynamic web pages in java
vishal choudhary
 
PDF
Building a Single Page Application with VueJS
danpastori
 
PPTX
Angular Universal
Janet Maldonado
 
PDF
Day In A Life Of A Node.js Developer
Edureka!
 
PDF
Day in a life of a node.js developer
Edureka!
 
PDF
Beginning MEAN Stack
Rob Davarnia
 
PPTX
NEXTjs.pptxfggfgfdgfgfdgfdgfdgfdgfdgfdgfg
zmulani8
 
PDF
How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?
Katy Slemon
 
Server side programming
javed ahmed
 
Node js getting started
Pallavi Srivastava
 
An Overview of Node.js
Ayush Mishra
 
SocketStream
Paul Jensen
 
server side rendering with angular JS.docx
React Masters
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
Architecting single-page front-end apps
Zohar Arad
 
NodeJS @ ACS
Mauro Parra-Miranda
 
AngularJS with Slim PHP Micro Framework
Backand Cohen
 
Integrating React.js Into a PHP Application: Dutch PHP 2019
Andrew Rota
 
React loadable
George Bukhanov
 
Dynamic web pages in java
vishal choudhary
 
Building a Single Page Application with VueJS
danpastori
 
Angular Universal
Janet Maldonado
 
Day In A Life Of A Node.js Developer
Edureka!
 
Day in a life of a node.js developer
Edureka!
 
Beginning MEAN Stack
Rob Davarnia
 
NEXTjs.pptxfggfgfdgfgfdgfdgfdgfdgfdgfdgfg
zmulani8
 
How to Build Real-time Chat App with Express, ReactJS, and Socket.IO?
Katy Slemon
 
Ad

Recently uploaded (20)

PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
DOCX
Import Data Form Excel to Tally Services
Tally xperts
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
PPTX
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
PPTX
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
PDF
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PPTX
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Import Data Form Excel to Tally Services
Tally xperts
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 

Web with Nodejs

  • 2. what is javascript? nothing to do with java a complete language moving parts of a web page not just window.open()
  • 3. nodejs And then came Node.js. JavaScript on the server, how cool is that? Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event- driven, non-blocking I/O model.
  • 4. nodejs Node.js is really two things: a runtime environment and a library
  • 5. why nodejs? much easier to setup and faster to code a web app in node.js than any other MVC (models, views, controllers) framework (say, django, flask etc). great for single page apps Odyssey 15 website was hosted on a five lines of code server. WUT? :O node.js is faster, (HELL YEAH!)
  • 6. node in ONE loc (ONE LINE TO RULE THEM ALL) server.js ------------------------------------------------------------------- console.log(“Hello, Byld”); terminal --------------------------------------------------------------- ---- $ node server.js Hello, Byld $
  • 7. event driven event loop: listens for events and calls a callback function once an event has been detected single thread event-driven programming is application flow control that is determined by events or changes in state.
  • 8. non blocking code (for real) var result = database.query("SELECT * FROM hugetable"); console.log("Hello World"); event-driven, asynchronous callbacks, by utilizing an event loop.
  • 9. non blocking code (for real) var result = database.query("SELECT * FROM hugetable"); console.log("Hello World"); event-driven, asynchronous callbacks, by utilizing an event loop. database.query("SELECT * FROM hugetable", function (rows) { var result = rows; }); console.log("Hello World");
  • 10. npm Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world. dependency tree
  • 11. Ok, this stuff is boring, right? Let’s write some real stuff. We will now create a web application serving a basic purpose of “file-uploading”
  • 12. What will our application do? 1. The user should be able to use our web-app on their browser. 2. The user should see a welcome page on http://localhost:3000/go 3. On the above web-page, there should be a file-upload form which accepts image files 4. On submitting the form, the user will be redirected to http://localhost:3000/upload where user will see the uploaded image
  • 13. what do we need for this? 1. To server HTTP requests - A HTTP server. 2. Our server will answer differently to requests, depending on the URL we need some kind of router which maps requests to request /handlers. 3. We need request handlers once the server has successfully routed a URL request. a. This request handler should be able to handle the POST data coming through static HTML page from our website b. We have to store the image temporarily on the server storage and show it in the /upload. 4. Once the requested URL is routed to proper route and the incoming data is retrieved from that request, we will show that image on next URL (‘/upload’)
  • 14. let the coding begin
  • 16. middlewares app.use() listens to the requests and runs some code selectively example express.static

Editor's Notes

  • #2: start with prerequisities
  • #3: compiler, operating system, apps on JS
  • #4: In order to execute the JavaScript you intend to run in the backend, it needs to be interpreted and, well, executed. This is what Node.js does, by making use of Google’s V8 VM, the same runtime environment for JavaScript that Google Chrome uses
  • #5: In order to execute the JavaScript you intend to run in the backend, it needs to be interpreted and, well, executed. This is what Node.js does, by making use of Google’s V8 VM, the same runtime environment for JavaScript that Google Chrome uses
  • #8: event control c in terminal touch event listener in your phone
  • #9: different xxectuion from python, ruby, java etc php
  • #10: different xxectuion from python, ruby, java etc example of php When at some point in the future the database server is done and sends the result of the query, then I have to execute the anonymous function that was passed to database.query().
  • #14: Make some coding slides. http://rmdaustralia.com.au/wp-content/uploads/2014/03/nodebeginner.pdf