SlideShare a Scribd company logo
Introduction toNode.JSFrom “Hello, World!” to Deploying on Azure#dunDDD29thNovember 2014Colin Mackayhttp://colinmackay.scot
Overview•What is node.js•Obligatory Hello, World! •Dependencies & node package manager•Web applications in node
What is node.js? Officially: 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. http://nodejs.org/
What is node.js, really? •A platform for executing JavaScript–Server-side–Modular–Non-blocking (async) code–Built-in networking, HTTP & WebSocketshttp://nodejs.org/
What are the advantages? •All running on one environment–No worries about browser compatibility–Google’s V8 Engine•ECMAScript 5 –up-to-date JS•Optimisation•JIT compiled•Non-blockinghttp://nodejs.org/
Typical StackMEAN•MongoDB(Database) •Express *(Web Framework) •Angular.js(UI Framework) •Node.js *(Platform) * This talk will introduce these topicshttp://www.mongodb.org/ http://expressjs.com/ https://angularjs.org/ http://nodejs.org/
Windows Installer•Add to PATH ensure available at any command prompt  •I wish more windows installers would do thishttp://nodejs.org/
IDEs for node.jsJetBrainsWeb StormVisual Studio Add-inhttp://nodejstools.codeplex.com/http://www.jetbrains.com/webstorm/
Hello World!
Splitting code across files•One large file would be horrible•Require(“./file.js”) •Module.exports•Can be hierarchical
DEMO #1Require & module.exports
Requiring a folder•Need a file to describe the folder–Index.js–Packages.json{ "name" : "my-library", "main" : "./lib/my-library.js" } •Exports from index/packages returned via requires
Node Package Manager•Like NuGet, but for node.js•Packages go in node_modulesfolder•Install with npminstall <name> –Add --saveto reference it in your app’s package.jsonto exclude it from source control. https://www.npmjs.org/
Package.json•JSON formatted file•Stores dependency information•npminstallto rebuild the dependencies–Useful after getting from source controlhttps://www.npmjs.org/doc/files/package.json.html
Package.json: example 
{ "name": "hello-world", "version": "0.0.1", "dependencies": { "express": "^4.10.3" } }
DEMO #2Node Package Manager
Express•Web Application Framework•Related to –Sinatra (Ruby) –Nancy (.NET) •“Fast, unopinionated, minimalist web framework for Node.js” http://expressjs.com/
Installing Express•npminstall express
Express: Hello, World! (1) // Requirementsvarexpress = require("express"); varhttp = require("http"); // Set up the applicationvarapp = express(); app.set("port", process.env.PORT|| 3000); // Run up the serverhttp.createServer(app).listen(app.get("port"), function(){ console.log("Express server listening on port " + app.get("port")); }); http://colinmackay.scot/2014/11/15/express-for-node-js-walk-through-hello-world/
Express: Hello, World! (2) module.exports= function(req, res) { res.send( "<h1>"+ "Hello, World!"+ "</h1>"); }; http://colinmackay.scot/2014/11/15/express-for-node-js-walk-through-hello-world/
Express: Hello, World! (3) •Need to add routing details to app.js•Supports most common HTTP verbs–And some uncommon onesapp.get("/", routeGetFunc); app.post("/", routePostFunc); app.put("/", routePutFunc); app.delete("/", routeDeleteFunc); http://colinmackay.scot/2014/11/15/express-for-node-js-walk-through-hello-world/
DEMO #3Express Hello World
Express IDE Support•IDE Support–VS AddInhas three templates–WebStormhas one template, but it’s more configurable.
Express Template•Express Template sets many things up for you•Completely configurable•Could throw most of this away for a basic app
Jade –View Engine
View Engines•Handlebars.js•JSHTML•Mustache/ Hogan.js•Underscore templates•Vash–Based on Razor Syntax
View Engines : EJS•EJS = Embedded JavaScript–Based on ERB (Embedded Ruby) –Similar to ASP.NET WebFormsview engine•No master page/layout support–Package for that! http://colinmackay.scot/2014/11/16/express-for-node-js-view-engines/
Static Files•Defaults to safty•Configure directories to expose•More complex rules possible 
app.use( 
express.static( 
__dirname+ '/public')); http://colinmackay.scot/2014/11/16/express-for-node-js-view-engines/
DEMO #4View Engines and Static Fileshttp://colinmackay.scot/2014/11/16/express-for-node-js-view-engines/
Processing form data•It’s a middleware–Many parsers available–Common: body-parser•Values available in req.bodyhttp://colinmackay.scot/2014/11/17/node-js-with-express-getting-form-data/
Body-parser setup & useApp.js 
varbodyParser= 
require("body-parser"); 
… 
app.use( 
bodyParser.urlencoded()); setLanguage.js 
varlanguage = req.body.language; http://colinmackay.scot/2014/11/17/node-js-with-express-getting-form-data/
Processing Cookies•Parsing cookies is middleware–Common: cookie-parser•Values available in req.cookies•Write values with res.cookie() •Clear cookie with res.clearCookie() –Much easier than .NEThttp://colinmackay.scot/2014/11/18/node-js-with-express-come-to-the-dark-side- we-have-cookies/
Cookie-parser setup & useApp.jssetLanguage.js 
varcookieParser= 
require("cookie-parser"); 
… 
app.use(cookieParser()); 
varlanguage = req.body.language; 
varcookieAge= 24*60*60*1000; // 1 day 
res.cookie( 
"flashcard-language", 
language, 
{ maxAge:cookieAge, 
httpOnly:true}); http://colinmackay.scot/2014/11/18/node-js-with-express-come-to-the-dark-side- we-have-cookies/
Cookie-parser setup & useFlashcard.jsWelcome.js 
varlanguage = 
req.cookies[ 
"flashcard-language"]; 
res.clearCookie( 
"flashcard-language"); http://colinmackay.scot/2014/11/18/node-js-with-express-come-to-the-dark-side- we-have-cookies/
DEMO #5Body & Cookie Parsinghttp://colinmackay.scot/2014/11/17/node-js-with-express-getting-form-data/ http://colinmackay.scot/2014/11/18/node-js-with-express-come-to-the-dark-side- we-have-cookies/
Deploying to Azure•Surprisingly easy–Almost…  •Deploy via source control
DEMO #6Deploying to Azurehttp://colinmackay.scot/2014/11/23/deploying-a-node-js-with-express-application- on-azure/
Deploying to Azure (1)
Deploying to Azure (2)
Deploying to Azure (3) http://colinmackay.scot/2014/11/23/deploying-a-node-js-with-express-application- on-azure/
Deploying to Azure (4) http://colinmackay.scot/2014/11/23/deploying-a-node-js-with-express-application- on-azure/
An issue with the imageshttp://colinmackay.scot/2014/11/23/deploying-a-node-js-with-express-application- on-azure/
Diagnosing the issueMissing imageMissing resource
Fixing the web.config 
<staticContent> 
<mimeMapfileExtension=".svg" mimeType="image/svg+xml" /> 
</staticContent> http://colinmackay.scot/2014/11/23/deploying-a-node-js-with-express-application- on-azure/
Finally working
Follow up information•Blog: http://colinmackay.scot/ –Slide deck available soon•Twitter: @colinmackay
Introduction to Node.JSQuestion Timehttp://colinmackay.scot/tag/node-js/
Follow up information•Blog: http://colinmackay.scot/ –Slide deck available soon•Twitter: @colinmackay
Ad

More Related Content

What's hot (20)

Nodejs getting started
Nodejs getting startedNodejs getting started
Nodejs getting started
Triet Ho
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
Nurul Ferdous
 
Node js Introduction
Node js IntroductionNode js Introduction
Node js Introduction
sanskriti agarwal
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Vikash Singh
 
NodeJS ecosystem
NodeJS ecosystemNodeJS ecosystem
NodeJS ecosystem
Yukti Kaura
 
Node js
Node jsNode js
Node js
Chirag Parmar
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express
Jeetendra singh
 
Nodejs vatsal shah
Nodejs vatsal shahNodejs vatsal shah
Nodejs vatsal shah
Vatsal N Shah
 
Node js for enterprise
Node js for enterpriseNode js for enterprise
Node js for enterprise
ravisankar munusamy
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
Jibanananda Sana
 
Node js training (1)
Node js training (1)Node js training (1)
Node js training (1)
Ashish Gupta
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Rob O'Doherty
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
Dinesh U
 
Nodejs presentation
Nodejs presentationNodejs presentation
Nodejs presentation
Arvind Devaraj
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
JITENDRA KUMAR PATEL
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
Arun Kumar Arjunan
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.js
Gary Yeh
 
An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)
iFour Technolab Pvt. Ltd.
 
Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7
Devang Garach
 
Nodejs
NodejsNodejs
Nodejs
Prem Sanil
 
Nodejs getting started
Nodejs getting startedNodejs getting started
Nodejs getting started
Triet Ho
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
Nurul Ferdous
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Vikash Singh
 
NodeJS ecosystem
NodeJS ecosystemNodeJS ecosystem
NodeJS ecosystem
Yukti Kaura
 
RESTful API In Node Js using Express
RESTful API In Node Js using Express RESTful API In Node Js using Express
RESTful API In Node Js using Express
Jeetendra singh
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
Jibanananda Sana
 
Node js training (1)
Node js training (1)Node js training (1)
Node js training (1)
Ashish Gupta
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
Rob O'Doherty
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
Dinesh U
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
JITENDRA KUMAR PATEL
 
Basic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.jsBasic Understanding and Implement of Node.js
Basic Understanding and Implement of Node.js
Gary Yeh
 
An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)An Introduction of Node Package Manager (NPM)
An Introduction of Node Package Manager (NPM)
iFour Technolab Pvt. Ltd.
 
Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7
Devang Garach
 

Viewers also liked (20)

Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.js
Marcus Frödin
 
Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。
Tatsuya Tobioka
 
EmpireJS: Hacking Art with Node js and Image Analysis
EmpireJS: Hacking Art with Node js and Image AnalysisEmpireJS: Hacking Art with Node js and Image Analysis
EmpireJS: Hacking Art with Node js and Image Analysis
jeresig
 
Debugging node in prod
Debugging node in prodDebugging node in prod
Debugging node in prod
Yunong Xiao
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.js
Ryan Anklam
 
NodeJS for Beginner
NodeJS for BeginnerNodeJS for Beginner
NodeJS for Beginner
Apaichon Punopas
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with Examples
Gabriele Lana
 
Nodejs Intro Part One
Nodejs Intro Part OneNodejs Intro Part One
Nodejs Intro Part One
Budh Ram Gurung
 
Hello world - intro to node js
Hello world - intro to node jsHello world - intro to node js
Hello world - intro to node js
Refresh Annapolis Valley
 
Node.js – ask us anything!
Node.js – ask us anything! Node.js – ask us anything!
Node.js – ask us anything!
Dev_Events
 
Building A Web App In 100% JavaScript with Carl Bergenhem
 Building A Web App In 100% JavaScript with Carl Bergenhem Building A Web App In 100% JavaScript with Carl Bergenhem
Building A Web App In 100% JavaScript with Carl Bergenhem
FITC
 
Pengenalan Dasar NodeJS
Pengenalan Dasar NodeJSPengenalan Dasar NodeJS
Pengenalan Dasar NodeJS
alfi setyadi
 
Knonex
KnonexKnonex
Knonex
knonex software development
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 
Node js mongodriver
Node js mongodriverNode js mongodriver
Node js mongodriver
christkv
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web App
Edureka!
 
#7 "Многообещающий JavaScript – Promises" Денис Речкунов
#7 "Многообещающий JavaScript – Promises" Денис Речкунов#7 "Многообещающий JavaScript – Promises" Денис Речкунов
#7 "Многообещающий JavaScript – Promises" Денис Речкунов
JSib
 
From Hello World to Real World - Container Days Boston 2016
From Hello World to Real World - Container Days Boston 2016From Hello World to Real World - Container Days Boston 2016
From Hello World to Real World - Container Days Boston 2016
Shannon Williams
 
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...
Calvin Tan
 
Asynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaAsynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and Java
James Falkner
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.js
Marcus Frödin
 
Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。Node.js ― Hello, world! の1歩先へ。
Node.js ― Hello, world! の1歩先へ。
Tatsuya Tobioka
 
EmpireJS: Hacking Art with Node js and Image Analysis
EmpireJS: Hacking Art with Node js and Image AnalysisEmpireJS: Hacking Art with Node js and Image Analysis
EmpireJS: Hacking Art with Node js and Image Analysis
jeresig
 
Debugging node in prod
Debugging node in prodDebugging node in prod
Debugging node in prod
Yunong Xiao
 
Modern UI Development With Node.js
Modern UI Development With Node.jsModern UI Development With Node.js
Modern UI Development With Node.js
Ryan Anklam
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with Examples
Gabriele Lana
 
Node.js – ask us anything!
Node.js – ask us anything! Node.js – ask us anything!
Node.js – ask us anything!
Dev_Events
 
Building A Web App In 100% JavaScript with Carl Bergenhem
 Building A Web App In 100% JavaScript with Carl Bergenhem Building A Web App In 100% JavaScript with Carl Bergenhem
Building A Web App In 100% JavaScript with Carl Bergenhem
FITC
 
Pengenalan Dasar NodeJS
Pengenalan Dasar NodeJSPengenalan Dasar NodeJS
Pengenalan Dasar NodeJS
alfi setyadi
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
Mohammad Qureshi
 
Node js mongodriver
Node js mongodriverNode js mongodriver
Node js mongodriver
christkv
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web App
Edureka!
 
#7 "Многообещающий JavaScript – Promises" Денис Речкунов
#7 "Многообещающий JavaScript – Promises" Денис Речкунов#7 "Многообещающий JavaScript – Promises" Денис Речкунов
#7 "Многообещающий JavaScript – Promises" Денис Речкунов
JSib
 
From Hello World to Real World - Container Days Boston 2016
From Hello World to Real World - Container Days Boston 2016From Hello World to Real World - Container Days Boston 2016
From Hello World to Real World - Container Days Boston 2016
Shannon Williams
 
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...
Why Node, Express and Postgres - presented 23 Feb 15, Talkjs, Microsoft Audit...
Calvin Tan
 
Asynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaAsynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and Java
James Falkner
 
Ad

Similar to Introduction to node js - From "hello world" to deploying on azure (20)

Nodejs web,db,hosting
Nodejs web,db,hostingNodejs web,db,hosting
Nodejs web,db,hosting
Kenu, GwangNam Heo
 
Extending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.jsExtending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.js
Petr Jiricka
 
Docker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukDocker based Architecture by Denys Serdiuk
Docker based Architecture by Denys Serdiuk
Lohika_Odessa_TechTalks
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
async_io
 
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
Troy Miles
 
Intro to Sails.js
Intro to Sails.jsIntro to Sails.js
Intro to Sails.js
DevOpsDays Austin 2014
 
The MEAN Stack
The MEAN StackThe MEAN Stack
The MEAN Stack
Md. Ziaul Haq
 
Mongo and node mongo dc 2011
Mongo and node mongo dc 2011Mongo and node mongo dc 2011
Mongo and node mongo dc 2011
async_io
 
Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?
Christian Joudrey
 
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
Ahmed Assaf
 
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
Sreenivas Kappala
 
Open shift and docker - october,2014
Open shift and docker - october,2014Open shift and docker - october,2014
Open shift and docker - october,2014
Hojoong Kim
 
Short-Training asp.net vNext
Short-Training asp.net vNextShort-Training asp.net vNext
Short-Training asp.net vNext
Betclic Everest Group Tech Team
 
Deploying windows containers with kubernetes
Deploying windows containers with kubernetesDeploying windows containers with kubernetes
Deploying windows containers with kubernetes
Ben Hall
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
orkaplan
 
nodejs_at_a_glance, understanding java script
nodejs_at_a_glance, understanding java scriptnodejs_at_a_glance, understanding java script
nodejs_at_a_glance, understanding java script
mohammedarshadhussai4
 
ASP .Net Core SPA Templates
ASP .Net Core SPA TemplatesASP .Net Core SPA Templates
ASP .Net Core SPA Templates
Eamonn Boyle
 
Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)
Lucas Jellema
 
18CSC311J WEB DESIGN AND DEVELOPMENT UNIT-4
18CSC311J WEB DESIGN AND DEVELOPMENT UNIT-418CSC311J WEB DESIGN AND DEVELOPMENT UNIT-4
18CSC311J WEB DESIGN AND DEVELOPMENT UNIT-4
Sivakumar M
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
WalaSidhom1
 
Extending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.jsExtending Build to the Client: A Maven User's Guide to Grunt.js
Extending Build to the Client: A Maven User's Guide to Grunt.js
Petr Jiricka
 
Docker based Architecture by Denys Serdiuk
Docker based Architecture by Denys SerdiukDocker based Architecture by Denys Serdiuk
Docker based Architecture by Denys Serdiuk
Lohika_Odessa_TechTalks
 
Practical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
async_io
 
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
Troy Miles
 
Mongo and node mongo dc 2011
Mongo and node mongo dc 2011Mongo and node mongo dc 2011
Mongo and node mongo dc 2011
async_io
 
Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?Introduction to Node.js: What, why and how?
Introduction to Node.js: What, why and how?
Christian Joudrey
 
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
Ahmed Assaf
 
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
Sreenivas Kappala
 
Open shift and docker - october,2014
Open shift and docker - october,2014Open shift and docker - october,2014
Open shift and docker - october,2014
Hojoong Kim
 
Deploying windows containers with kubernetes
Deploying windows containers with kubernetesDeploying windows containers with kubernetes
Deploying windows containers with kubernetes
Ben Hall
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
orkaplan
 
nodejs_at_a_glance, understanding java script
nodejs_at_a_glance, understanding java scriptnodejs_at_a_glance, understanding java script
nodejs_at_a_glance, understanding java script
mohammedarshadhussai4
 
ASP .Net Core SPA Templates
ASP .Net Core SPA TemplatesASP .Net Core SPA Templates
ASP .Net Core SPA Templates
Eamonn Boyle
 
Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)
Lucas Jellema
 
18CSC311J WEB DESIGN AND DEVELOPMENT UNIT-4
18CSC311J WEB DESIGN AND DEVELOPMENT UNIT-418CSC311J WEB DESIGN AND DEVELOPMENT UNIT-4
18CSC311J WEB DESIGN AND DEVELOPMENT UNIT-4
Sivakumar M
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
WalaSidhom1
 
Ad

Recently uploaded (20)

Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Adobe Photoshop Lightroom CC 2025 Crack Latest Version
Adobe Photoshop Lightroom CC 2025 Crack Latest VersionAdobe Photoshop Lightroom CC 2025 Crack Latest Version
Adobe Photoshop Lightroom CC 2025 Crack Latest Version
usmanhidray
 
Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025
Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025
Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025
wareshashahzadiii
 
Salesforce Aged Complex Org Revitalization Process .pdf
Salesforce Aged Complex Org Revitalization Process .pdfSalesforce Aged Complex Org Revitalization Process .pdf
Salesforce Aged Complex Org Revitalization Process .pdf
SRINIVASARAO PUSULURI
 
Sales Deck SentinelOne Singularity Platform.pptx
Sales Deck SentinelOne Singularity Platform.pptxSales Deck SentinelOne Singularity Platform.pptx
Sales Deck SentinelOne Singularity Platform.pptx
EliandoLawnote
 
Mastering OOP: Understanding the Four Core Pillars
Mastering OOP: Understanding the Four Core PillarsMastering OOP: Understanding the Four Core Pillars
Mastering OOP: Understanding the Four Core Pillars
Marcel David
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Adobe Photoshop Lightroom CC 2025 Crack Latest Version
Adobe Photoshop Lightroom CC 2025 Crack Latest VersionAdobe Photoshop Lightroom CC 2025 Crack Latest Version
Adobe Photoshop Lightroom CC 2025 Crack Latest Version
usmanhidray
 
Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025
Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025
Minitab 22 Full Crack Plus Product Key Free Download [Latest] 2025
wareshashahzadiii
 
Salesforce Aged Complex Org Revitalization Process .pdf
Salesforce Aged Complex Org Revitalization Process .pdfSalesforce Aged Complex Org Revitalization Process .pdf
Salesforce Aged Complex Org Revitalization Process .pdf
SRINIVASARAO PUSULURI
 
Sales Deck SentinelOne Singularity Platform.pptx
Sales Deck SentinelOne Singularity Platform.pptxSales Deck SentinelOne Singularity Platform.pptx
Sales Deck SentinelOne Singularity Platform.pptx
EliandoLawnote
 
Mastering OOP: Understanding the Four Core Pillars
Mastering OOP: Understanding the Four Core PillarsMastering OOP: Understanding the Four Core Pillars
Mastering OOP: Understanding the Four Core Pillars
Marcel David
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 

Introduction to node js - From "hello world" to deploying on azure

  • 1. Introduction toNode.JSFrom “Hello, World!” to Deploying on Azure#dunDDD29thNovember 2014Colin Mackayhttp://colinmackay.scot
  • 2. Overview•What is node.js•Obligatory Hello, World! •Dependencies & node package manager•Web applications in node
  • 3. What is node.js? Officially: 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. http://nodejs.org/
  • 4. What is node.js, really? •A platform for executing JavaScript–Server-side–Modular–Non-blocking (async) code–Built-in networking, HTTP & WebSocketshttp://nodejs.org/
  • 5. What are the advantages? •All running on one environment–No worries about browser compatibility–Google’s V8 Engine•ECMAScript 5 –up-to-date JS•Optimisation•JIT compiled•Non-blockinghttp://nodejs.org/
  • 6. Typical StackMEAN•MongoDB(Database) •Express *(Web Framework) •Angular.js(UI Framework) •Node.js *(Platform) * This talk will introduce these topicshttp://www.mongodb.org/ http://expressjs.com/ https://angularjs.org/ http://nodejs.org/
  • 7. Windows Installer•Add to PATH ensure available at any command prompt  •I wish more windows installers would do thishttp://nodejs.org/
  • 8. IDEs for node.jsJetBrainsWeb StormVisual Studio Add-inhttp://nodejstools.codeplex.com/http://www.jetbrains.com/webstorm/
  • 10. Splitting code across files•One large file would be horrible•Require(“./file.js”) •Module.exports•Can be hierarchical
  • 11. DEMO #1Require & module.exports
  • 12. Requiring a folder•Need a file to describe the folder–Index.js–Packages.json{ "name" : "my-library", "main" : "./lib/my-library.js" } •Exports from index/packages returned via requires
  • 13. Node Package Manager•Like NuGet, but for node.js•Packages go in node_modulesfolder•Install with npminstall <name> –Add --saveto reference it in your app’s package.jsonto exclude it from source control. https://www.npmjs.org/
  • 14. Package.json•JSON formatted file•Stores dependency information•npminstallto rebuild the dependencies–Useful after getting from source controlhttps://www.npmjs.org/doc/files/package.json.html
  • 15. Package.json: example { "name": "hello-world", "version": "0.0.1", "dependencies": { "express": "^4.10.3" } }
  • 17. Express•Web Application Framework•Related to –Sinatra (Ruby) –Nancy (.NET) •“Fast, unopinionated, minimalist web framework for Node.js” http://expressjs.com/
  • 19. Express: Hello, World! (1) // Requirementsvarexpress = require("express"); varhttp = require("http"); // Set up the applicationvarapp = express(); app.set("port", process.env.PORT|| 3000); // Run up the serverhttp.createServer(app).listen(app.get("port"), function(){ console.log("Express server listening on port " + app.get("port")); }); http://colinmackay.scot/2014/11/15/express-for-node-js-walk-through-hello-world/
  • 20. Express: Hello, World! (2) module.exports= function(req, res) { res.send( "<h1>"+ "Hello, World!"+ "</h1>"); }; http://colinmackay.scot/2014/11/15/express-for-node-js-walk-through-hello-world/
  • 21. Express: Hello, World! (3) •Need to add routing details to app.js•Supports most common HTTP verbs–And some uncommon onesapp.get("/", routeGetFunc); app.post("/", routePostFunc); app.put("/", routePutFunc); app.delete("/", routeDeleteFunc); http://colinmackay.scot/2014/11/15/express-for-node-js-walk-through-hello-world/
  • 23. Express IDE Support•IDE Support–VS AddInhas three templates–WebStormhas one template, but it’s more configurable.
  • 24. Express Template•Express Template sets many things up for you•Completely configurable•Could throw most of this away for a basic app
  • 27. View Engines : EJS•EJS = Embedded JavaScript–Based on ERB (Embedded Ruby) –Similar to ASP.NET WebFormsview engine•No master page/layout support–Package for that! http://colinmackay.scot/2014/11/16/express-for-node-js-view-engines/
  • 28. Static Files•Defaults to safty•Configure directories to expose•More complex rules possible app.use( express.static( __dirname+ '/public')); http://colinmackay.scot/2014/11/16/express-for-node-js-view-engines/
  • 29. DEMO #4View Engines and Static Fileshttp://colinmackay.scot/2014/11/16/express-for-node-js-view-engines/
  • 30. Processing form data•It’s a middleware–Many parsers available–Common: body-parser•Values available in req.bodyhttp://colinmackay.scot/2014/11/17/node-js-with-express-getting-form-data/
  • 31. Body-parser setup & useApp.js varbodyParser= require("body-parser"); … app.use( bodyParser.urlencoded()); setLanguage.js varlanguage = req.body.language; http://colinmackay.scot/2014/11/17/node-js-with-express-getting-form-data/
  • 32. Processing Cookies•Parsing cookies is middleware–Common: cookie-parser•Values available in req.cookies•Write values with res.cookie() •Clear cookie with res.clearCookie() –Much easier than .NEThttp://colinmackay.scot/2014/11/18/node-js-with-express-come-to-the-dark-side- we-have-cookies/
  • 33. Cookie-parser setup & useApp.jssetLanguage.js varcookieParser= require("cookie-parser"); … app.use(cookieParser()); varlanguage = req.body.language; varcookieAge= 24*60*60*1000; // 1 day res.cookie( "flashcard-language", language, { maxAge:cookieAge, httpOnly:true}); http://colinmackay.scot/2014/11/18/node-js-with-express-come-to-the-dark-side- we-have-cookies/
  • 34. Cookie-parser setup & useFlashcard.jsWelcome.js varlanguage = req.cookies[ "flashcard-language"]; res.clearCookie( "flashcard-language"); http://colinmackay.scot/2014/11/18/node-js-with-express-come-to-the-dark-side- we-have-cookies/
  • 35. DEMO #5Body & Cookie Parsinghttp://colinmackay.scot/2014/11/17/node-js-with-express-getting-form-data/ http://colinmackay.scot/2014/11/18/node-js-with-express-come-to-the-dark-side- we-have-cookies/
  • 36. Deploying to Azure•Surprisingly easy–Almost…  •Deploy via source control
  • 37. DEMO #6Deploying to Azurehttp://colinmackay.scot/2014/11/23/deploying-a-node-js-with-express-application- on-azure/
  • 40. Deploying to Azure (3) http://colinmackay.scot/2014/11/23/deploying-a-node-js-with-express-application- on-azure/
  • 41. Deploying to Azure (4) http://colinmackay.scot/2014/11/23/deploying-a-node-js-with-express-application- on-azure/
  • 42. An issue with the imageshttp://colinmackay.scot/2014/11/23/deploying-a-node-js-with-express-application- on-azure/
  • 43. Diagnosing the issueMissing imageMissing resource
  • 44. Fixing the web.config <staticContent> <mimeMapfileExtension=".svg" mimeType="image/svg+xml" /> </staticContent> http://colinmackay.scot/2014/11/23/deploying-a-node-js-with-express-application- on-azure/
  • 46. Follow up information•Blog: http://colinmackay.scot/ –Slide deck available soon•Twitter: @colinmackay
  • 47. Introduction to Node.JSQuestion Timehttp://colinmackay.scot/tag/node-js/
  • 48. Follow up information•Blog: http://colinmackay.scot/ –Slide deck available soon•Twitter: @colinmackay