SlideShare uma empresa Scribd logo
1 de 13
Baixar para ler offline
SenchaLabs Connect & Express
           High Performance Servers written in JavaScript
Monday, September 20, 2010
Why we need non-blocking
                  Polling is too slow and inefficient.

                  Live interaction requires the server to push data.

                  In order to push data, the connections need to be
                  persistent.

                  The server needs to handle thousands of
                  persistent connections.

                  Threads aren’t going to scale.


Monday, September 20, 2010
Why we need JavaScript
                  You already use it in the client.
                  It’s already event based and not threaded.
                  It’s actually a good language if used right.
                  Lambdas, closures, garbage collection.
                  V8 is a really fast VM


Monday, September 20, 2010
Node's goal is to provide an easy way to build
       performant network programs.

       This is in contrast to today's more common
       concurrency model where OS threads are
       employed.

       Node programs are written in JavaScript.
Monday, September 20, 2010
Hello World in Node.js
        // Load the http module
        var http = require('http');

        // Setup a request handler for a simple HTTP server.
        // Listen on port 3000
        http.createServer(function (req, res) {
          res.writeHead(200, {'Content-Type': 'text/
        plain'});
          res.end('Hello Worldn');
        }).listen(3000, "127.0.0.1");

        // Print a pretty message to the terminal
        console.log('Server running at http://
        127.0.0.1:3000/');

Monday, September 20, 2010
Hello World in Connect
             // Load the connect module
             Connect = require('connect');
             // Setup a simple Connect server
             server = Connect.createServer(
                function (req, res) {
                  res.writeHead(200, {
                    'Content-Type': 'text/plain'
                  });
                  res.end('Hello Worldn');
                }
             );
             // Export the server so Spark can run it
             module.exports = server;

Monday, September 20, 2010
Stacking in Middleware
                  Node provides very low level APIs

                  There is no cookie handling or parsing.

                  There is no session support built-in.

                  There is no routing built-in.

                  There is no static file serving.

                  Connect makes this easy!


Monday, September 20, 2010
Bundled Modules
                  Static File Server   Fancy Error Handler

                  Apache Style Logs    Cache Manifest

                  Body Decoder         Conditional Get

                  Cookie Decoder       Inline Gzipping

                  Session Provider     Virtual Host Router

                  Request Router       Sass/Less Compiler



Monday, September 20, 2010
Connect with Layers
                  Connect.createServer(
                     Connect.logger(),
                     Connect.conditionalGet(),
                     Connect.cache(),
                     Connect.gzip(),
                     Connect.staticProvider("public"),
                     Connect.bodyDecoder(),
                     Connect.cookieDecoder(),
                     Connect.session(),
                     Connect.router(routes),
                     Connect.errorHandler({showStack:
                  true})
                  );

Monday, September 20, 2010
Express is even easier
                  Connect is a framework maker’s framework.

                  It’s much easier than raw node.js, but still low
                  level.

                  Express is a simple framework for application
                  developers.

                  It’s inspired by Sinatra from the Ruby world.



Monday, September 20, 2010
Express Example
                   // Create an express app
                   var app = express.createServer();

                   // Setup a route handler
                   app.get('/', function(req, res){
                       res.send('Hello World');
                   });

                   // Start the HTTP server
                   app.listen(3000);


Monday, September 20, 2010
DEMO TIME!


Monday, September 20, 2010
Links to Projects Used
            http://senchalabs.github.com/connect

            http://expressjs.com

            http://nodejs.org

            http://raphaeljs.com




Monday, September 20, 2010

Mais conteúdo relacionado

Mais procurados

Quick Introduction to Node.js
Quick Introduction to Node.jsQuick Introduction to Node.js
Quick Introduction to Node.jsNaing Lin Aung
 
Windows Azure loves OSS
Windows Azure loves OSSWindows Azure loves OSS
Windows Azure loves OSSKazumi Hirose
 
Virtual Infrastructure
Virtual InfrastructureVirtual Infrastructure
Virtual InfrastructureBryan McLellan
 
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...itsatony
 
Vagrant 101 Workshop
Vagrant 101 WorkshopVagrant 101 Workshop
Vagrant 101 WorkshopLiora Milbaum
 
Ember and WebSockets
Ember and WebSocketsEmber and WebSockets
Ember and WebSocketsSteve Kinney
 
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingOnce upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingAndrea Giannantonio
 
Windows vps hosting providers
Windows vps hosting providersWindows vps hosting providers
Windows vps hosting providerscoreymueller60
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2Wyatt Fang
 
My journey from PHP to Node.js
My journey from PHP to Node.jsMy journey from PHP to Node.js
My journey from PHP to Node.jsValentin Lup
 
Why Bundler 1.1 will be much faster
Why Bundler 1.1 will be much fasterWhy Bundler 1.1 will be much faster
Why Bundler 1.1 will be much fasterPat Shaughnessy
 
Brig:Node.js + QML 華麗大冒險
Brig:Node.js + QML 華麗大冒險Brig:Node.js + QML 華麗大冒險
Brig:Node.js + QML 華麗大冒險Fred Chien
 
Minicurso de Vagrant
Minicurso de VagrantMinicurso de Vagrant
Minicurso de VagrantLeandro Nunes
 

Mais procurados (18)

Quick Introduction to Node.js
Quick Introduction to Node.jsQuick Introduction to Node.js
Quick Introduction to Node.js
 
Windows Azure loves OSS
Windows Azure loves OSSWindows Azure loves OSS
Windows Azure loves OSS
 
Virtual Infrastructure
Virtual InfrastructureVirtual Infrastructure
Virtual Infrastructure
 
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
VisualWeb - Building a NodeJS Server Meshwork and Full-Javascript Stack Frame...
 
Nodejs Intro
Nodejs IntroNodejs Intro
Nodejs Intro
 
Vagrant 101 Workshop
Vagrant 101 WorkshopVagrant 101 Workshop
Vagrant 101 Workshop
 
Ember and WebSockets
Ember and WebSocketsEmber and WebSockets
Ember and WebSockets
 
Once upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side renderingOnce upon a time, there were css, js and server-side rendering
Once upon a time, there were css, js and server-side rendering
 
Socket.io
Socket.ioSocket.io
Socket.io
 
Windows vps hosting providers
Windows vps hosting providersWindows vps hosting providers
Windows vps hosting providers
 
Session#1
Session#1Session#1
Session#1
 
Express js
Express jsExpress js
Express js
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2
 
My journey from PHP to Node.js
My journey from PHP to Node.jsMy journey from PHP to Node.js
My journey from PHP to Node.js
 
Why Bundler 1.1 will be much faster
Why Bundler 1.1 will be much fasterWhy Bundler 1.1 will be much faster
Why Bundler 1.1 will be much faster
 
Vi
ViVi
Vi
 
Brig:Node.js + QML 華麗大冒險
Brig:Node.js + QML 華麗大冒險Brig:Node.js + QML 華麗大冒險
Brig:Node.js + QML 華麗大冒險
 
Minicurso de Vagrant
Minicurso de VagrantMinicurso de Vagrant
Minicurso de Vagrant
 

Semelhante a SenchaLabs Connect & Express

node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
 
Muduo network library
Muduo network libraryMuduo network library
Muduo network libraryShuo Chen
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSocketsGonzalo Ayuso
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 
Node.js introduction
Node.js introductionNode.js introduction
Node.js introductionParth Joshi
 
Real time web_apps_pycon2012-v1
Real time web_apps_pycon2012-v1Real time web_apps_pycon2012-v1
Real time web_apps_pycon2012-v1Avinash Prasad
 
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersWebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersViktor Gamov
 
JavaScript, Meet Cloud: Node.js on Windows Azure
JavaScript, Meet Cloud: Node.js on Windows AzureJavaScript, Meet Cloud: Node.js on Windows Azure
JavaScript, Meet Cloud: Node.js on Windows AzureSasha Goldshtein
 
KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享Chia Wei Tsai
 
HTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebHTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebPeter Lubbers
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS drupalcampest
 
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01purans
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsitnig
 
Writing & Using Web Services
Writing & Using Web ServicesWriting & Using Web Services
Writing & Using Web ServicesRajarshi Guha
 
Testing frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabsTesting frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabsTudor Barbu
 

Semelhante a SenchaLabs Connect & Express (20)

The HTML5 WebSocket API
The HTML5 WebSocket APIThe HTML5 WebSocket API
The HTML5 WebSocket API
 
node.js: Javascript's in your backend
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
Node.js Introduction
Node.js IntroductionNode.js Introduction
Node.js Introduction
 
Muduo network library
Muduo network libraryMuduo network library
Muduo network library
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
Proposal
ProposalProposal
Proposal
 
Node.js introduction
Node.js introductionNode.js introduction
Node.js introduction
 
Real time web_apps_pycon2012-v1
Real time web_apps_pycon2012-v1Real time web_apps_pycon2012-v1
Real time web_apps_pycon2012-v1
 
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersWebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
 
JavaScript, Meet Cloud: Node.js on Windows Azure
JavaScript, Meet Cloud: Node.js on Windows AzureJavaScript, Meet Cloud: Node.js on Windows Azure
JavaScript, Meet Cloud: Node.js on Windows Azure
 
KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享KSDG-iSlide App 開發心得分享
KSDG-iSlide App 開發心得分享
 
HTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebHTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the Web
 
Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS Developing realtime apps with Drupal and NodeJS
Developing realtime apps with Drupal and NodeJS
 
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
 
jWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerry
jWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerryjWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerry
jWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerry
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Writing & Using Web Services
Writing & Using Web ServicesWriting & Using Web Services
Writing & Using Web Services
 
Testing frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabsTesting frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabs
 

Último

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Último (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

SenchaLabs Connect & Express

  • 1. SenchaLabs Connect & Express High Performance Servers written in JavaScript Monday, September 20, 2010
  • 2. Why we need non-blocking Polling is too slow and inefficient. Live interaction requires the server to push data. In order to push data, the connections need to be persistent. The server needs to handle thousands of persistent connections. Threads aren’t going to scale. Monday, September 20, 2010
  • 3. Why we need JavaScript You already use it in the client. It’s already event based and not threaded. It’s actually a good language if used right. Lambdas, closures, garbage collection. V8 is a really fast VM Monday, September 20, 2010
  • 4. Node's goal is to provide an easy way to build performant network programs. This is in contrast to today's more common concurrency model where OS threads are employed. Node programs are written in JavaScript. Monday, September 20, 2010
  • 5. Hello World in Node.js // Load the http module var http = require('http'); // Setup a request handler for a simple HTTP server. // Listen on port 3000 http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/ plain'}); res.end('Hello Worldn'); }).listen(3000, "127.0.0.1"); // Print a pretty message to the terminal console.log('Server running at http:// 127.0.0.1:3000/'); Monday, September 20, 2010
  • 6. Hello World in Connect // Load the connect module Connect = require('connect'); // Setup a simple Connect server server = Connect.createServer( function (req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello Worldn'); } ); // Export the server so Spark can run it module.exports = server; Monday, September 20, 2010
  • 7. Stacking in Middleware Node provides very low level APIs There is no cookie handling or parsing. There is no session support built-in. There is no routing built-in. There is no static file serving. Connect makes this easy! Monday, September 20, 2010
  • 8. Bundled Modules Static File Server Fancy Error Handler Apache Style Logs Cache Manifest Body Decoder Conditional Get Cookie Decoder Inline Gzipping Session Provider Virtual Host Router Request Router Sass/Less Compiler Monday, September 20, 2010
  • 9. Connect with Layers Connect.createServer( Connect.logger(), Connect.conditionalGet(), Connect.cache(), Connect.gzip(), Connect.staticProvider("public"), Connect.bodyDecoder(), Connect.cookieDecoder(), Connect.session(), Connect.router(routes), Connect.errorHandler({showStack: true}) ); Monday, September 20, 2010
  • 10. Express is even easier Connect is a framework maker’s framework. It’s much easier than raw node.js, but still low level. Express is a simple framework for application developers. It’s inspired by Sinatra from the Ruby world. Monday, September 20, 2010
  • 11. Express Example // Create an express app var app = express.createServer(); // Setup a route handler app.get('/', function(req, res){ res.send('Hello World'); }); // Start the HTTP server app.listen(3000); Monday, September 20, 2010
  • 13. Links to Projects Used http://senchalabs.github.com/connect http://expressjs.com http://nodejs.org http://raphaeljs.com Monday, September 20, 2010