SlideShare a Scribd company logo
1 of 58
Download to read offline
node.js for front-end
                                developers

                               Garann Means // garann.com

Saturday, October 1, 2011
Saturday, October 1, 2011
case you missed it
                     ⬢      about two years old
                     ⬢      web server
                     ⬢      V8 as a backend platform
                     ⬢      all evented everything
                     ⬢      write in JavaScript




Saturday, October 1, 2011
hello world




                                          http://nodejs.org

Saturday, October 1, 2011
great, but..



Saturday, October 1, 2011
things node is good at
                     ⬢      chat apps
                     ⬢      games
                     ⬢      prototyping




Saturday, October 1, 2011
also: websites.



Saturday, October 1, 2011
fat clients
                     ⬢      client managing state
                     ⬢      client-side copy of data
                     ⬢      server just provides persistence




Saturday, October 1, 2011
connecting to APIs
                     ⬢      minimal persistence needs on your own
                            server
                     ⬢      easily avoid cross-domain issues
                     ⬢      callbacks on the server instead of JSONP




Saturday, October 1, 2011
real-time
                     ⬢      great for collaborative apps
                     ⬢      everything’s evented
                     ⬢      pushing and polling feel more natural
                     ⬢      excellent tools and abstractions




Saturday, October 1, 2011
things servers do
                     ⬢      15 years of JavaScript
                            ⬢   anything you’d ever want to do in a
                                browser
                     ⬢      2 years of node
                            ⬢   anything you’d ever want to do on the
                                backend




Saturday, October 1, 2011
hello $$$




                                http://www.braintreepayments.com/docs/node
Saturday, October 1, 2011
the question you
                            should be asking is,
                                 “why not?”


Saturday, October 1, 2011
node out of the box
                     ⬢      http, https, URL and querystring tools
                     ⬢      file system tools
                     ⬢      basic debugging, console logging, REPL
                     ⬢      timers, setInterval, etc.
                     ⬢      events and custom events




Saturday, October 1, 2011
require(‘other stuff’);



Saturday, October 1, 2011
node modules
                // myModule.js

                var myModule = exports;

                myModule.add = function(num1, num2) {
                  return num1 + num2;
                }




Saturday, October 1, 2011
node modules
                // server.js

                var addition = require(“myModule”);

                console.log(addition.add(4,5));   // “9”




Saturday, October 1, 2011
node modules




Saturday, October 1, 2011
node modules
                     ⬢      http://search.npmjs.org

                     ⬢      github
                     ⬢      99% chance that what you want exists
                     ⬢      use caution!
                            ⬢   check for multiple use cases
                            ⬢   check whether it’s still maintained




Saturday, October 1, 2011
writing less and
                             doing more*

                               * for the back-end


Saturday, October 1, 2011
express




                                      http://expressjs.com

Saturday, October 1, 2011
express
                     ⬢      application framework
                     ⬢      simple default file structure
                            ⬢   setup as easy as “express”
                     ⬢      routing
                     ⬢      template rendering
                     ⬢      sessions




Saturday, October 1, 2011
rendering a page
                var app = require('express').createServer();

                app.configure(function(){
                 app.set('view engine', 'html');
                 app.register('.html', require('jqtpl').express);
                });




Saturday, October 1, 2011
rendering a page
                app.get('/',function(req, res) {
                	
                  if (req.session && req.session.uid) {
                	     return res.redirect('/user');
                	 }
                	 res.render('login');

                });



Saturday, October 1, 2011
easy routing
                app.get('/user/:name', function(req, res) {

                       res.render('user', {
                          username: req.params.name
                       });

                });




Saturday, October 1, 2011
easy sessions
                var express = require(' express '),
                 app = express.createServer(),
                 connect = require(' connect ');

                app.configure(function(){
                 app.use(express.bodyParser());
                 app.use(express.cookieParser());
                 app.use(express.session());
                });


Saturday, October 1, 2011
easy sessions
                app.post('/login',function(req, res) {
                	
                  req.session.uid = req.body.username;
                  res.redirect('/');

                });




Saturday, October 1, 2011
socket.io




                                        http://socket.io
Saturday, October 1, 2011
socket.io
                     ⬢      easy-as-pie async communication
                     ⬢      functions similar to EventEmitter
                            ⬢   emit:on :: publish:subscribe
                            ⬢   same for client or server
                     ⬢      advanced stuff: context, broadcast
                     ⬢      works like.. JavaScript!




Saturday, October 1, 2011
plays nice w/ express
                var express = require(' express '),
                 app = express.createServer(),
                 connect = require(' connect '),
                 io = require('socket.io').listen(app);

                io.sockets.on('connection', function(socket) {
                 ...
                });



Saturday, October 1, 2011
(or not)




                                       http://socket.io/#howtouse

Saturday, October 1, 2011
easy client setup
                <script src="/socket.io/socket.io.js"></script>

                <script>
                 var socket =
                  io.connect('http://localhost:1337');
                </script>




Saturday, October 1, 2011
publish events
                <input type=”text” id=”username” />
                <input type=”button” id=”btn” value=”log in” />
                <script>
                 ...
                 $(“#btn”).click(function() {
                   socket.emit(“login”, $(“#username”).val());
                 });
                </script>



Saturday, October 1, 2011
publish events
                socket.on(“login”, function (name) {

                   socket.set(“uid”, name, function () {
                      socket.emit(“loggedIn”,name);
                  });

                });




Saturday, October 1, 2011
subscribe to events
                socket.on(“bookmark”, function(data) {

                    socket.get(“uid”, function(err, uid) {
                     addBookmark(uid, data.page, data.title);
                     socket.emit(“bmarkSaved”, data);
                    });

                });



Saturday, October 1, 2011
subscribe to events
                <script>
                 ...
                 socket.on(“bmarkSaved”, function(data) {
                   var bmark =
                     new Bmark(data.page, data.name);
                   bmark.render();
                 });
                </script>



Saturday, October 1, 2011
oh yay.
                            more code to write.


Saturday, October 1, 2011
sharing code
                     ⬢      possibly the best part?
                     ⬢      template reuse
                     ⬢      object reuse
                     ⬢      mostly: convention and tool reuse
                            ⬢   pub/sub and callbacks
                            ⬢   underscore, even jQuery!
                            ⬢   backbone and friends



Saturday, October 1, 2011
templates
                     ⬢      does it require the DOM?
                     ⬢      does it require compilation?
                     ⬢      no + no == probably works for both client-
                            and server-side
                            ⬢   jQuery templates
                            ⬢   mustache
                            ⬢   and many more!



Saturday, October 1, 2011
objects




                             http://www.2ality.com/2011/08/universal-modules.html

Saturday, October 1, 2011
callbacks
                     ⬢      user events
                     ⬢      messages to the server
                     ⬢      responses to the client
                     ⬢      database operations
                     ⬢      calls to APIs
                     ⬢      everything!




Saturday, October 1, 2011
jQuery in node
                     ⬢      installs as easily as any other npm module
                     ⬢      gets its own dependencies (jsdom)
                     ⬢      DOM manipulation
                     ⬢      wait, what?




Saturday, October 1, 2011
jQuery in node
                     ⬢      if you have complex existing code that
                            depends on jQuery
                     ⬢      if you need to write a scraper
                     ⬢      if you need to dig through some HTML (e.g.
                            spidering)
                     ⬢      if you want to simulate user interaction




Saturday, October 1, 2011
underscore in node
                     ⬢      works awesome with jQuery
                     ⬢      works awesome with node!
                     ⬢      same utilities on both sides, same code
                     ⬢      if you don’t have a specific use case for
                            jQuery




Saturday, October 1, 2011
frameworks
                     ⬢      backbone
                            ⬢   http://andyet.net/blog/2011/feb/15/re-using-backbonejs-models-on-the-
                                server-with-node/

                     ⬢      spine
                            ⬢   http://maccman.github.com/spine.tutorials/node.html

                     ⬢      in theory, anything




Saturday, October 1, 2011
ok, but when
                            will it be ready?


Saturday, October 1, 2011
totes ready!




Saturday, October 1, 2011
ok, no, really.



Saturday, October 1, 2011
Saturday, October 1, 2011
Saturday, October 1, 2011
Saturday, October 1, 2011
Saturday, October 1, 2011
Saturday, October 1, 2011
Saturday, October 1, 2011
(your pet project)



Saturday, October 1, 2011
we’ve seen this before
           2011



           2007



           2004



           2000
                                                     server-side      client-side


           1996
              alert()       hotscripts   libraries   app frameworks     modern JS


Saturday, October 1, 2011
totes ready
                     ⬢      basic HTTP stuff is solid
                     ⬢      excellent tools already exist
                     ⬢      client-side work can be reused
                     ⬢      you know JavaScript
                     ⬢      you can make a web application. now.




Saturday, October 1, 2011
thanks!
                            @garannm / garann@gmail.com




Saturday, October 1, 2011

More Related Content

Viewers also liked

Tms、cms与运营
Tms、cms与运营Tms、cms与运营
Tms、cms与运营zhifei
 
Developing with Cassandra
Developing with CassandraDeveloping with Cassandra
Developing with CassandraSperasoft
 
KillrChat: Building Your First Application in Apache Cassandra (English)
KillrChat: Building Your First Application in Apache Cassandra (English)KillrChat: Building Your First Application in Apache Cassandra (English)
KillrChat: Building Your First Application in Apache Cassandra (English)DataStax Academy
 
Node.js and Cassandra
Node.js and CassandraNode.js and Cassandra
Node.js and CassandraStratio
 
Cassandra NodeJS driver & NodeJS Paris
Cassandra NodeJS driver & NodeJS ParisCassandra NodeJS driver & NodeJS Paris
Cassandra NodeJS driver & NodeJS ParisDuyhai Doan
 
Real-time Cassandra
Real-time CassandraReal-time Cassandra
Real-time CassandraAcunu
 
Application Development with Apache Cassandra as a Service
Application Development with Apache Cassandra as a ServiceApplication Development with Apache Cassandra as a Service
Application Development with Apache Cassandra as a ServiceWSO2
 
The Deloitte CFO Survey 2015 Q1
The Deloitte CFO Survey 2015 Q1The Deloitte CFO Survey 2015 Q1
The Deloitte CFO Survey 2015 Q1Deloitte UK
 
Synnex 2015 Line Card + Warehouses
Synnex  2015 Line Card + WarehousesSynnex  2015 Line Card + Warehouses
Synnex 2015 Line Card + WarehousesMary Armenta
 
Portfólio Empresas UPTEC 2013_EN
Portfólio Empresas UPTEC 2013_ENPortfólio Empresas UPTEC 2013_EN
Portfólio Empresas UPTEC 2013_ENUPTEC
 
2_White Paper Electronic Meal Ordering
2_White Paper Electronic Meal Ordering2_White Paper Electronic Meal Ordering
2_White Paper Electronic Meal OrderingChristopher Morgan
 
Kiosk+Solutions+issue+5
Kiosk+Solutions+issue+5Kiosk+Solutions+issue+5
Kiosk+Solutions+issue+5Adrian Warne
 
Surviving the new retail reality | Ard van Leeuwen | Kega
Surviving the new retail reality |  Ard van Leeuwen | KegaSurviving the new retail reality |  Ard van Leeuwen | Kega
Surviving the new retail reality | Ard van Leeuwen | KegaMooreStephensBE
 
CSS3: A practical introduction (FT2010 talk)
CSS3: A practical introduction (FT2010 talk)CSS3: A practical introduction (FT2010 talk)
CSS3: A practical introduction (FT2010 talk)Lea Verou
 
Accenture Retail Clienteling Solution
Accenture Retail Clienteling SolutionAccenture Retail Clienteling Solution
Accenture Retail Clienteling SolutionTarik Schmidt
 
Using Cassandra with your Web Application
Using Cassandra with your Web ApplicationUsing Cassandra with your Web Application
Using Cassandra with your Web Applicationsupertom
 
KWD Webranking Sweden 2012-2013
KWD Webranking Sweden 2012-2013 KWD Webranking Sweden 2012-2013
KWD Webranking Sweden 2012-2013 Comprend
 

Viewers also liked (20)

Tms、cms与运营
Tms、cms与运营Tms、cms与运营
Tms、cms与运营
 
Developing with Cassandra
Developing with CassandraDeveloping with Cassandra
Developing with Cassandra
 
KillrChat: Building Your First Application in Apache Cassandra (English)
KillrChat: Building Your First Application in Apache Cassandra (English)KillrChat: Building Your First Application in Apache Cassandra (English)
KillrChat: Building Your First Application in Apache Cassandra (English)
 
Node.js and Cassandra
Node.js and CassandraNode.js and Cassandra
Node.js and Cassandra
 
Cassandra NodeJS driver & NodeJS Paris
Cassandra NodeJS driver & NodeJS ParisCassandra NodeJS driver & NodeJS Paris
Cassandra NodeJS driver & NodeJS Paris
 
Real-time Cassandra
Real-time CassandraReal-time Cassandra
Real-time Cassandra
 
Application Development with Apache Cassandra as a Service
Application Development with Apache Cassandra as a ServiceApplication Development with Apache Cassandra as a Service
Application Development with Apache Cassandra as a Service
 
The Deloitte CFO Survey 2015 Q1
The Deloitte CFO Survey 2015 Q1The Deloitte CFO Survey 2015 Q1
The Deloitte CFO Survey 2015 Q1
 
OmniCX-Datasheet
OmniCX-DatasheetOmniCX-Datasheet
OmniCX-Datasheet
 
Synnex 2015 Line Card + Warehouses
Synnex  2015 Line Card + WarehousesSynnex  2015 Line Card + Warehouses
Synnex 2015 Line Card + Warehouses
 
Portfólio Empresas UPTEC 2013_EN
Portfólio Empresas UPTEC 2013_ENPortfólio Empresas UPTEC 2013_EN
Portfólio Empresas UPTEC 2013_EN
 
2_White Paper Electronic Meal Ordering
2_White Paper Electronic Meal Ordering2_White Paper Electronic Meal Ordering
2_White Paper Electronic Meal Ordering
 
Kiosk+Solutions+issue+5
Kiosk+Solutions+issue+5Kiosk+Solutions+issue+5
Kiosk+Solutions+issue+5
 
Arbetslösheten i Svenskfinland i oktober 2014
Arbetslösheten i Svenskfinland i oktober 2014Arbetslösheten i Svenskfinland i oktober 2014
Arbetslösheten i Svenskfinland i oktober 2014
 
Surviving the new retail reality | Ard van Leeuwen | Kega
Surviving the new retail reality |  Ard van Leeuwen | KegaSurviving the new retail reality |  Ard van Leeuwen | Kega
Surviving the new retail reality | Ard van Leeuwen | Kega
 
RealityMine for ARF March 2015
RealityMine for ARF March 2015RealityMine for ARF March 2015
RealityMine for ARF March 2015
 
CSS3: A practical introduction (FT2010 talk)
CSS3: A practical introduction (FT2010 talk)CSS3: A practical introduction (FT2010 talk)
CSS3: A practical introduction (FT2010 talk)
 
Accenture Retail Clienteling Solution
Accenture Retail Clienteling SolutionAccenture Retail Clienteling Solution
Accenture Retail Clienteling Solution
 
Using Cassandra with your Web Application
Using Cassandra with your Web ApplicationUsing Cassandra with your Web Application
Using Cassandra with your Web Application
 
KWD Webranking Sweden 2012-2013
KWD Webranking Sweden 2012-2013 KWD Webranking Sweden 2012-2013
KWD Webranking Sweden 2012-2013
 

Similar to node.js for front-end developers

Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSCaridy Patino
 
A Look at the Future of HTML5
A Look at the Future of HTML5A Look at the Future of HTML5
A Look at the Future of HTML5Tim Wright
 
The Fast, The Slow and the Lazy
The Fast, The Slow and the LazyThe Fast, The Slow and the Lazy
The Fast, The Slow and the LazyMaurício Linhares
 
Community Code: The TouchForums App
Community Code: The TouchForums AppCommunity Code: The TouchForums App
Community Code: The TouchForums AppSencha
 
Community Code: Xero
Community Code: XeroCommunity Code: Xero
Community Code: XeroSencha
 
Rendering Views in JavaScript - "The New Web Architecture"
Rendering Views in JavaScript - "The New Web Architecture"Rendering Views in JavaScript - "The New Web Architecture"
Rendering Views in JavaScript - "The New Web Architecture"Jonathan Julian
 
Javascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJSJavascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJSSylvain Zimmer
 
3D in the Browser via WebGL: It's Go Time
3D in the Browser via WebGL: It's Go Time 3D in the Browser via WebGL: It's Go Time
3D in the Browser via WebGL: It's Go Time Pascal Rettig
 
Practical Cloud Security
Practical Cloud SecurityPractical Cloud Security
Practical Cloud SecurityJason Chan
 
What's this NetKernel Thing Anyway?
What's this NetKernel Thing Anyway?What's this NetKernel Thing Anyway?
What's this NetKernel Thing Anyway?Darren Cruse
 
Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011
Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011
Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011hugs
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to SolrErik Hatcher
 
Contextual Plone Security SaaS & SOA
Contextual Plone Security SaaS & SOAContextual Plone Security SaaS & SOA
Contextual Plone Security SaaS & SOAKen Wasetis
 
Javascript - How to avoid the bad parts
Javascript - How to avoid the bad partsJavascript - How to avoid the bad parts
Javascript - How to avoid the bad partsMikko Ohtamaa
 
AppScale Talk at SBonRails
AppScale Talk at SBonRailsAppScale Talk at SBonRails
AppScale Talk at SBonRailsChris Bunch
 

Similar to node.js for front-end developers (20)

Caridy patino - node-js
Caridy patino - node-jsCaridy patino - node-js
Caridy patino - node-js
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JS
 
A Look at the Future of HTML5
A Look at the Future of HTML5A Look at the Future of HTML5
A Look at the Future of HTML5
 
Groke
GrokeGroke
Groke
 
The Fast, The Slow and the Lazy
The Fast, The Slow and the LazyThe Fast, The Slow and the Lazy
The Fast, The Slow and the Lazy
 
Community Code: The TouchForums App
Community Code: The TouchForums AppCommunity Code: The TouchForums App
Community Code: The TouchForums App
 
RunDeck
RunDeckRunDeck
RunDeck
 
Node at artsy
Node at artsyNode at artsy
Node at artsy
 
Community Code: Xero
Community Code: XeroCommunity Code: Xero
Community Code: Xero
 
Rendering Views in JavaScript - "The New Web Architecture"
Rendering Views in JavaScript - "The New Web Architecture"Rendering Views in JavaScript - "The New Web Architecture"
Rendering Views in JavaScript - "The New Web Architecture"
 
Javascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJSJavascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJS
 
3D in the Browser via WebGL: It's Go Time
3D in the Browser via WebGL: It's Go Time 3D in the Browser via WebGL: It's Go Time
3D in the Browser via WebGL: It's Go Time
 
Practical Cloud Security
Practical Cloud SecurityPractical Cloud Security
Practical Cloud Security
 
What's this NetKernel Thing Anyway?
What's this NetKernel Thing Anyway?What's this NetKernel Thing Anyway?
What's this NetKernel Thing Anyway?
 
Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011
Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011
Extreme Testing with Selenium - @hugs at Jenkins User Conference 2011
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to Solr
 
Contextual Plone Security SaaS & SOA
Contextual Plone Security SaaS & SOAContextual Plone Security SaaS & SOA
Contextual Plone Security SaaS & SOA
 
Javascript - How to avoid the bad parts
Javascript - How to avoid the bad partsJavascript - How to avoid the bad parts
Javascript - How to avoid the bad parts
 
High Availability Server Apps
High Availability Server AppsHigh Availability Server Apps
High Availability Server Apps
 
AppScale Talk at SBonRails
AppScale Talk at SBonRailsAppScale Talk at SBonRails
AppScale Talk at SBonRails
 

Recently uploaded

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 

Recently uploaded (20)

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 

node.js for front-end developers

  • 1. node.js for front-end developers Garann Means // garann.com Saturday, October 1, 2011
  • 3. case you missed it ⬢ about two years old ⬢ web server ⬢ V8 as a backend platform ⬢ all evented everything ⬢ write in JavaScript Saturday, October 1, 2011
  • 4. hello world http://nodejs.org Saturday, October 1, 2011
  • 6. things node is good at ⬢ chat apps ⬢ games ⬢ prototyping Saturday, October 1, 2011
  • 8. fat clients ⬢ client managing state ⬢ client-side copy of data ⬢ server just provides persistence Saturday, October 1, 2011
  • 9. connecting to APIs ⬢ minimal persistence needs on your own server ⬢ easily avoid cross-domain issues ⬢ callbacks on the server instead of JSONP Saturday, October 1, 2011
  • 10. real-time ⬢ great for collaborative apps ⬢ everything’s evented ⬢ pushing and polling feel more natural ⬢ excellent tools and abstractions Saturday, October 1, 2011
  • 11. things servers do ⬢ 15 years of JavaScript ⬢ anything you’d ever want to do in a browser ⬢ 2 years of node ⬢ anything you’d ever want to do on the backend Saturday, October 1, 2011
  • 12. hello $$$ http://www.braintreepayments.com/docs/node Saturday, October 1, 2011
  • 13. the question you should be asking is, “why not?” Saturday, October 1, 2011
  • 14. node out of the box ⬢ http, https, URL and querystring tools ⬢ file system tools ⬢ basic debugging, console logging, REPL ⬢ timers, setInterval, etc. ⬢ events and custom events Saturday, October 1, 2011
  • 16. node modules // myModule.js var myModule = exports; myModule.add = function(num1, num2) { return num1 + num2; } Saturday, October 1, 2011
  • 17. node modules // server.js var addition = require(“myModule”); console.log(addition.add(4,5)); // “9” Saturday, October 1, 2011
  • 19. node modules ⬢ http://search.npmjs.org ⬢ github ⬢ 99% chance that what you want exists ⬢ use caution! ⬢ check for multiple use cases ⬢ check whether it’s still maintained Saturday, October 1, 2011
  • 20. writing less and doing more* * for the back-end Saturday, October 1, 2011
  • 21. express http://expressjs.com Saturday, October 1, 2011
  • 22. express ⬢ application framework ⬢ simple default file structure ⬢ setup as easy as “express” ⬢ routing ⬢ template rendering ⬢ sessions Saturday, October 1, 2011
  • 23. rendering a page var app = require('express').createServer(); app.configure(function(){ app.set('view engine', 'html'); app.register('.html', require('jqtpl').express); }); Saturday, October 1, 2011
  • 24. rendering a page app.get('/',function(req, res) { if (req.session && req.session.uid) { return res.redirect('/user'); } res.render('login'); }); Saturday, October 1, 2011
  • 25. easy routing app.get('/user/:name', function(req, res) { res.render('user', { username: req.params.name }); }); Saturday, October 1, 2011
  • 26. easy sessions var express = require(' express '), app = express.createServer(), connect = require(' connect '); app.configure(function(){ app.use(express.bodyParser()); app.use(express.cookieParser()); app.use(express.session()); }); Saturday, October 1, 2011
  • 27. easy sessions app.post('/login',function(req, res) { req.session.uid = req.body.username; res.redirect('/'); }); Saturday, October 1, 2011
  • 28. socket.io http://socket.io Saturday, October 1, 2011
  • 29. socket.io ⬢ easy-as-pie async communication ⬢ functions similar to EventEmitter ⬢ emit:on :: publish:subscribe ⬢ same for client or server ⬢ advanced stuff: context, broadcast ⬢ works like.. JavaScript! Saturday, October 1, 2011
  • 30. plays nice w/ express var express = require(' express '), app = express.createServer(), connect = require(' connect '), io = require('socket.io').listen(app); io.sockets.on('connection', function(socket) { ... }); Saturday, October 1, 2011
  • 31. (or not) http://socket.io/#howtouse Saturday, October 1, 2011
  • 32. easy client setup <script src="/socket.io/socket.io.js"></script> <script> var socket = io.connect('http://localhost:1337'); </script> Saturday, October 1, 2011
  • 33. publish events <input type=”text” id=”username” /> <input type=”button” id=”btn” value=”log in” /> <script> ... $(“#btn”).click(function() { socket.emit(“login”, $(“#username”).val()); }); </script> Saturday, October 1, 2011
  • 34. publish events socket.on(“login”, function (name) {    socket.set(“uid”, name, function () {       socket.emit(“loggedIn”,name); }); }); Saturday, October 1, 2011
  • 35. subscribe to events socket.on(“bookmark”, function(data) { socket.get(“uid”, function(err, uid) { addBookmark(uid, data.page, data.title); socket.emit(“bmarkSaved”, data); }); }); Saturday, October 1, 2011
  • 36. subscribe to events <script> ... socket.on(“bmarkSaved”, function(data) { var bmark = new Bmark(data.page, data.name); bmark.render(); }); </script> Saturday, October 1, 2011
  • 37. oh yay. more code to write. Saturday, October 1, 2011
  • 38. sharing code ⬢ possibly the best part? ⬢ template reuse ⬢ object reuse ⬢ mostly: convention and tool reuse ⬢ pub/sub and callbacks ⬢ underscore, even jQuery! ⬢ backbone and friends Saturday, October 1, 2011
  • 39. templates ⬢ does it require the DOM? ⬢ does it require compilation? ⬢ no + no == probably works for both client- and server-side ⬢ jQuery templates ⬢ mustache ⬢ and many more! Saturday, October 1, 2011
  • 40. objects http://www.2ality.com/2011/08/universal-modules.html Saturday, October 1, 2011
  • 41. callbacks ⬢ user events ⬢ messages to the server ⬢ responses to the client ⬢ database operations ⬢ calls to APIs ⬢ everything! Saturday, October 1, 2011
  • 42. jQuery in node ⬢ installs as easily as any other npm module ⬢ gets its own dependencies (jsdom) ⬢ DOM manipulation ⬢ wait, what? Saturday, October 1, 2011
  • 43. jQuery in node ⬢ if you have complex existing code that depends on jQuery ⬢ if you need to write a scraper ⬢ if you need to dig through some HTML (e.g. spidering) ⬢ if you want to simulate user interaction Saturday, October 1, 2011
  • 44. underscore in node ⬢ works awesome with jQuery ⬢ works awesome with node! ⬢ same utilities on both sides, same code ⬢ if you don’t have a specific use case for jQuery Saturday, October 1, 2011
  • 45. frameworks ⬢ backbone ⬢ http://andyet.net/blog/2011/feb/15/re-using-backbonejs-models-on-the- server-with-node/ ⬢ spine ⬢ http://maccman.github.com/spine.tutorials/node.html ⬢ in theory, anything Saturday, October 1, 2011
  • 46. ok, but when will it be ready? Saturday, October 1, 2011
  • 48. ok, no, really. Saturday, October 1, 2011
  • 55. (your pet project) Saturday, October 1, 2011
  • 56. we’ve seen this before 2011 2007 2004 2000 server-side client-side 1996 alert() hotscripts libraries app frameworks modern JS Saturday, October 1, 2011
  • 57. totes ready ⬢ basic HTTP stuff is solid ⬢ excellent tools already exist ⬢ client-side work can be reused ⬢ you know JavaScript ⬢ you can make a web application. now. Saturday, October 1, 2011
  • 58. thanks! @garannm / garann@gmail.com Saturday, October 1, 2011