SenchaLabs Connect & Express
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

SenchaLabs Connect & Express

on

  • 5,467 views

This is a talk I gave at a local ExtJS users group at Sencha headquarters.

This is a talk I gave at a local ExtJS users group at Sencha headquarters.

Statistics

Views

Total Views
5,467
Views on SlideShare
5,333
Embed Views
134

Actions

Likes
3
Downloads
43
Comments
0

4 Embeds 134

http://coderwall.com 128
http://www.linkedin.com 4
http://localhost:3000 1
https://si0.twimg.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

SenchaLabs Connect & Express Presentation Transcript

  • 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
  • 12. DEMO TIME! 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