advertisement

Introduction to Node.js Platform

50 %
50 %
advertisement
Information about Introduction to Node.js Platform
Technology

Published on February 18, 2014

Author: chintal75

Source: slideshare.net

Description

Introduction to Node.js & JavaScript Platform
advertisement

INTRODUCTION TO NODE.JS SERVER-SIDE JAVASCRIPT & EVENT-DRIVEN PLATFORM Naresh Chintalcheru

NODE.JS  Node.js is a platform to build fast, scalable and high-throughput network applications  Uses single-threaded Event-Loop & NonBlocking I/O model that makes it lightweight and efficient use of Server resources  JavaScript Runtime on the Server  Browser based IDE’s  No multi-thread locking burden on the runtime

JAVASCRIPT  JavaScript is an object-oriented and functional style scripting language  Runs on a single-threaded runtime  Dynamic Typing and Prototype-based var person1 = new Person(‘John’, ‘Smith’); Type-of-Variable Vs Type-of-Value

JAVASCRIPT  Dynamic Typing and Prototype-based language var person1 = new Person(‘John’, ‘Smith’);  No Person class but a Person Prototype var Person = function() { this.fname = ""; this.lname = ""; this.greet = function() { console.log("Hi, I'm " + this.fname); }; };

JAVASCRIPT INHERITANCE var Person = function() { this.fname = ""; this.lname = ""; }; var Employee = function() { this.title = ""; this.salary = ""; }; Employee.prototype = new Person();

JAVASCRIPT FUNCTIONS  Functions are the first-class citizens  Pass around Closure functions makes EventDriven programming simple  Closures  Pass functions to the method parameters  Method returns data or functions

SERVER-SIDE VS CLIENT-SIDE  JavaScript is born and live in the client-side browsers  Has ability to run on the server-side  Server-side JavaScript will not have the browser based global objects such as Window & Document but does have objects http/url etc provided by the Node.js platform

JAVASCRIPT RUNTIME  Node.js uses the Googles V8 JavaScript Engine used in chrome browser  V8 Runtime Engine uses Heap memory for JavaScript objects & functions  V8 has Garbage Collection for memory management  V8 JIT (Just-In-Time) Compiler

NODE.JS Understanding Node.js Code

NODE.JS Node.js is Platform + Runtime No need of a Web Server

NODE.JS SERVER var http = require("http"); Callback function function onRequest(request, response) { console.log("Request received."); response.writeHead(200, {"Content-Type": "text/plain"}); } response.write("Hello World"); response.end(); http.createServer(onRequest).listen(8080); console.log("Server has started.")

NODE.JS Routes & Request Handlers are Controllers/Models in MVC

NODE.JS SERVER var http = require("http"); function onRequest(request, response) { var pathname = url.parse(request.url).pathname; route(pathname); response.writeHead(200, {"Content-Type": "text/plain"}); } response.end(); http.createServer(onRequest).listen(8080); console.log("Server has started.") Route Handles /AddEmp /SearchEmp

EXPRESS.JS Express.js MVC framework for Node.js (Similar to Struts, JSF & SpringMVC for JEE)

EXPRESS.JS Express.js MVC Framework handles Routes, Request Handlers and Views for Node.js

EXPRESS.JS //start Express var express = require("express"); var app = express(); //set the view directory to /views app.set("views", __dirname + "/views"); app.set("view engine", "jade"); //Delete an Employee; Routes And Request Handlers app.post('/employee/delete:id/', function(req, res) { employeeProvider.delete(req.param('_id'), function(error, docs) {res.redirect('/')}) ;});

EXPRESS.JS //start Express var express = require("express"); var app = express(); var routes = require('./routes'); Struts-config.xml //set the view directory to /views app.set("views", __dirname + "/views"); app.set("view engine", "jade"); app.get('/emplist', routes.emplist(db)); app.get('/addemp', routes.addemp);

EXPRESS.JS & SPRING MVC //Express delete an Employee app.post('/employee/delete:id/', function(req, res) { employeeProvider.delete(req.param('_id'), function(error, docs) {res.redirect('/')}); }); //Spring MVC delete an Employee @Controller public class SpringMVCController { @RequestMapping(value = "/employee/delete", method = RequestMethod.GET) public String delete(@RequestParam("id") String name, Model model) { employeeDAO.delete(id); return “deleteSuccess"; }

DATA PERSISTENCE Node.js can access RDBMS and NoSQL Databases

DATA PERSISTENCE var mysql = require('mysql'); var conn = mysql.createConnection({ host : “localhost:3700”, user : “uid”, password: “pwd” }); conn.getConnection(function(err, connection){ connection.query( “select * from table1”, function(err, rows){ if(err) { throw err; }}); connection.release(); } );

THANK YOU Thank You

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

Introduction to Node.js | Pluralsight

Introduction to Node.js. ... Introduction 0m 38s Node.js Background 1m 51s Getting Node.js 1m 31s Demo: ... PLATFORM Browse library
Read more

Node.js

Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world. Download. v6.9.1 LTS Recommended For Most Users. Other ...
Read more

Node.js - Introduction - Tutorialspoint

Node.js Introduction - Learn Node.js framework in simple and easy steps ... What is Node.js? Node.js is a server-side platform built on Google ...
Read more

Introduction to Node.js on Windows Azure

Node.js is a platform for building fast and scalable applications in JavaScript. In this session you will learn how to build Node.js application and deploy ...
Read more

Node.js Step by Step: Introduction - code.tutsplus.com

Node.js is an amazing new technology, ... Platform Agnostic; Business; Programming; ... Node.js Step by Step: Introduction
Read more

Why The Hell Would I Use Node.js? A Case-by-Case Tutorial

Why The Hell Would I Use Node.js? ... Node.js is not the best platform around. No, ... Great introduction to node.js!
Read more

Introduction To NodeJS - C# Corner

In this article you will learn about an introduction to NodeJS. Node.js is a platform built on Chrome's JavaScript Runtime.
Read more

Introduction to Node.Js | Intel® Software

So we have been hearing a lot about node.js and its popular among web developers and ... Introduction to Node.Js. ... "node.js is a platform built on ...
Read more

An Absolute Beginner's Guide to Node.js - blog.modulus.io

Node.js is just another way to execute code on your ... Modulus is a premier hosting platform that provides a complete technology stack for application ...
Read more

About | Node.js

About Node.js ® As an asynchronous ... Please review the Trademark Guidelines of the Node.js Foundation. Linux Foundation is a registered trademark of The ...
Read more