24

node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless
Page 2: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

Node.JSNode.jsisanopensource,cross-platform,JavaScriptruntimebuiltonChrome'sV8JavaScriptengine,fordevelopingserverandclientsideapplications.Node.jsusesanevent-driven,non-blockingI/Omodelthatmakesitlightweightandefficient.

Page 3: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

Node’sgoalistoprovideaneasywaytobuildscalablenetworkprograms

Page 4: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

Install Node.jsFrom

http://nodejs.org

Page 5: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

ConsoleUse

Page 6: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

ExitConsole

Page 7: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

RunFile

Page 8: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

LoadFile

Page 9: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

Non-Blocking

Page 10: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless
Page 11: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

REQUESTS

EVENT LOOP(single thread)

EXPENSIVEOPERATION

FILE SYSTEM

DATABASE

COMPUTATION

Page 12: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

ArchitecturalShift1.old) webserverwithapplicationlogic1.new) appthatcanconnectandcollaborate

2.old) stateful2.new) stateless

Page 13: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

ArchitecturalShift1.old) blocking1.new) non-blocking

2.old) processperrequest2.new) singleprocess

Page 14: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

MODULES

Page 15: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

Packagemanager.Installs,publishesandmanagesnodeprograms

Whatisnpm?

https://www.npm

js.com

Page 16: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

Whatisnpm?LargestEcosystem

475KModules2.7Billion/Week

Page 17: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

Advantages• Smallpieces,looselyjoined• Leverageexternalpackages• Leverageinternalpackages• Facilitatecollaboration• Packagesarediscoverableinnpm

Page 18: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

WhatisaModule?AModuleissomeJavaScriptpairedwithapackage.jsonfile

+

Page 19: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

Make module with “module.exports”

Use module with “require”

Page 20: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

Creatingnode/npmapps

Page 21: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

“npm init” generates the configuration file package.json

Page 22: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

addingnpmpackagestoyourapplication

Page 23: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

Local installation of request package. Dependency added to package.json

Page 24: node - compuxo.org fileArchitectural Shift 1.old)web server with application logic 1.new)app that can connect and collaborate 2.old)stateful 2.new)stateless

ActiveLearning• …