WEEKLY PRESENTATION
DURING TRAINING PROGRAM
- Devang Garach
devanggarach.rao@gmail.com
WEEK-7
Information Technology
AGENDA - Fundamental of Node.JS
What is Node.JS
Features of Node.JS
Node.JS Architecture
Core modules in Node.JS
Node.JS Installation
npm
Creating first node.js application
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
What is Node.JS
Node.js is an open-source, back-end JavaScript runtime server environment.
It uses Google Chrome V8 engine and executes code.
It is cross platform environment and can run on OS X, Microsoft Windows,
Linux,...
Provides an event driven architecture and non blocking I/O that is optimized
and scalable.
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
Features of Node.JS
Asynchronous:
When request is made to server, instead of waiting for the request to
complete, server continues to process other requests.
When request processing completes, the response is sent to caller using
callback mechanism.
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
Caller Recipient
Request
Response
Callback
Asynchronous Model
Features of Node.JS (Continue...)
Single Thread and Event Driven:
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
Event Emitters
Event Queue
File System
Network
Process
Other
Event Loop
(Single - Threaded)
Features of Node.JS (Continue...)
Very Fast:
Being built on Google Chrome's V8 JavaScript Engine, Node.JS library is
very fast in code execution.
Single Threaded, but very highly scalable
Node.js highly scalable because event mechanism helps the server to
respond in non-blocking way
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
Node.JS Architecture
Requests
Incoming requests can be blocking (complex) or
non-blocking (simple), depending upon the tasks
that a user wants to perform in a web application
Node.js Server
Node.js server is a server-side platform that takes
requests from users, processes those requests,
and returns responses to the corresponding users.
Event Queue
Event Queue in a Node.js server stores incoming
client requests and passes those requests
one-by-one into the Event Loop
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
Node.JS Architecture (Continue...)
Thread Pool
Thread pool consists of all the threads available for
carrying out some tasks that might be required to
fulfill client requests
Event Loop
Event Loop indefinitely receives requests and
processes them, and then returns the responses to
corresponding clients
External Resources
External resources are required to deal with blocking
client requests. These resources can be for
computation, data storage, etc.
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
Core modules in Node.JS
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
Core
Module Description
http http module includes classes, methods and events to create Node.js http server.
url url module includes methods for URL resolution and parsing.
querystring querystring module includes methods to deal with query string.
path path module includes methods to deal with file paths.
fs fs module includes classes, methods, and events to work with file I/O.
util util module includes utility functions useful for programmers.
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
1. Download from official
website node.org/download
2. Install it in your compatible
OS
3. After installation,
check installation version
> node --v
Installation
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
Node Package Manager
A package in Node.js contains all
the files you need for a module.
Modules are JavaScript libraries
you can include in your project.
Downloading a package is very
easy. Open the command line
interface and tell NPM to
download the package you want.
> npm install express
We first have to use npm init , it
create package.jsonfile
npm
Creating first node.js program
1. Importing Module:
“require” is used to load a node.js modules
2. Creating Server:
Used to create web server object
Function (request,response) is called once
for every HTTP request to the server, so it’s
called the request handler
3. listen(<port_no>):
Bind the server instance for listening to a
particular port.
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
var http = require(“http”);
var server = http.createServer(
function(request, response){
console.log(‘creating server object’);
}
);
server.listen(port,function(
){
console.log(‘server running
at http://localhost:3000 ’)
}
);
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
To run node.js program
> node <nodejs_file>
Creating first node.js program (Continue...)
Thank You.
- Devang Garach
devanggarach.rao@gmail.com
Information Technology

Fundamental of Node.JS - Internship Presentation - Week7

  • 1.
    WEEKLY PRESENTATION DURING TRAININGPROGRAM - Devang Garach devanggarach.rao@gmail.com WEEK-7 Information Technology
  • 2.
    AGENDA - Fundamentalof Node.JS What is Node.JS Features of Node.JS Node.JS Architecture Core modules in Node.JS Node.JS Installation npm Creating first node.js application Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION
  • 3.
    What is Node.JS Node.jsis an open-source, back-end JavaScript runtime server environment. It uses Google Chrome V8 engine and executes code. It is cross platform environment and can run on OS X, Microsoft Windows, Linux,... Provides an event driven architecture and non blocking I/O that is optimized and scalable. Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION
  • 4.
    Features of Node.JS Asynchronous: Whenrequest is made to server, instead of waiting for the request to complete, server continues to process other requests. When request processing completes, the response is sent to caller using callback mechanism. Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION Caller Recipient Request Response Callback Asynchronous Model
  • 5.
    Features of Node.JS(Continue...) Single Thread and Event Driven: Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION Event Emitters Event Queue File System Network Process Other Event Loop (Single - Threaded)
  • 6.
    Features of Node.JS(Continue...) Very Fast: Being built on Google Chrome's V8 JavaScript Engine, Node.JS library is very fast in code execution. Single Threaded, but very highly scalable Node.js highly scalable because event mechanism helps the server to respond in non-blocking way Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION
  • 7.
    Node.JS Architecture Requests Incoming requestscan be blocking (complex) or non-blocking (simple), depending upon the tasks that a user wants to perform in a web application Node.js Server Node.js server is a server-side platform that takes requests from users, processes those requests, and returns responses to the corresponding users. Event Queue Event Queue in a Node.js server stores incoming client requests and passes those requests one-by-one into the Event Loop Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION
  • 8.
    Node.JS Architecture (Continue...) ThreadPool Thread pool consists of all the threads available for carrying out some tasks that might be required to fulfill client requests Event Loop Event Loop indefinitely receives requests and processes them, and then returns the responses to corresponding clients External Resources External resources are required to deal with blocking client requests. These resources can be for computation, data storage, etc. Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION
  • 9.
    Core modules inNode.JS Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION Core Module Description http http module includes classes, methods and events to create Node.js http server. url url module includes methods for URL resolution and parsing. querystring querystring module includes methods to deal with query string. path path module includes methods to deal with file paths. fs fs module includes classes, methods, and events to work with file I/O. util util module includes utility functions useful for programmers.
  • 10.
    Information Technology DURING TRAININGPROGRAM - WEEKLY PRESENTATION 1. Download from official website node.org/download 2. Install it in your compatible OS 3. After installation, check installation version > node --v Installation
  • 11.
    Information Technology DURING TRAININGPROGRAM - WEEKLY PRESENTATION Node Package Manager A package in Node.js contains all the files you need for a module. Modules are JavaScript libraries you can include in your project. Downloading a package is very easy. Open the command line interface and tell NPM to download the package you want. > npm install express We first have to use npm init , it create package.jsonfile npm
  • 12.
    Creating first node.jsprogram 1. Importing Module: “require” is used to load a node.js modules 2. Creating Server: Used to create web server object Function (request,response) is called once for every HTTP request to the server, so it’s called the request handler 3. listen(<port_no>): Bind the server instance for listening to a particular port. Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION var http = require(“http”); var server = http.createServer( function(request, response){ console.log(‘creating server object’); } ); server.listen(port,function( ){ console.log(‘server running at http://localhost:3000 ’) } );
  • 13.
    Information Technology DURING TRAININGPROGRAM - WEEKLY PRESENTATION To run node.js program > node <nodejs_file> Creating first node.js program (Continue...)
  • 14.
    Thank You. - DevangGarach devanggarach.rao@gmail.com Information Technology