Upgrade to Pro — share decks privately, control downloads, hide ads and more …

nodejs - step 1

Mot
March 05, 2012

nodejs - step 1

First in a series to Riverside JS on getting started with nodejs

Mot

March 05, 2012
Tweet

More Decks by Mot

Other Decks in Technology

Transcript

  1. 3/5/12 3:06 PM nodejs - step 1 Page 1 of

    9 file:///Users/scottmotte/code/javascript/node_step_1/presentation/presentation/index.html nodejs - step 1
  2. 3/5/12 3:06 PM nodejs - step 1 Page 2 of

    9 file:///Users/scottmotte/code/javascript/node_step_1/presentation/presentation/index.html About Me Freelance web developer at scottmotte.com I like to build things. My latest project is Gumb.io. Twitter: @scottmotte
  3. 3/5/12 3:06 PM nodejs - step 1 Page 3 of

    9 file:///Users/scottmotte/code/javascript/node_step_1/presentation/presentation/index.html What Serverside Javascript 2009 Most watched GitHub repository Ryan Dahl Asynchronous (Evented everything just liked browser based JavaScript)
  4. 3/5/12 3:06 PM nodejs - step 1 Page 4 of

    9 file:///Users/scottmotte/code/javascript/node_step_1/presentation/presentation/index.html Why Fast - 6K req/sec for hello world. Ubiquituous Language - Write in JavaScript. Great for real time apps - everything is evented. The Future - the new 'Ruby on Rails' link
  5. 3/5/12 3:06 PM nodejs - step 1 Page 5 of

    9 file:///Users/scottmotte/code/javascript/node_step_1/presentation/presentation/index.html Installation 1. Go here and download. 2. Follow the install instructions. 3. Revel in how much easier that was than Ruby and Rails has ever been.
  6. 3/5/12 3:06 PM nodejs - step 1 Page 6 of

    9 file:///Users/scottmotte/code/javascript/node_step_1/presentation/presentation/index.html First program - hello_world.js 1. Create file called hello_world.js with the following code. var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(1337, '127.0.0.1'); console.log('Server running at http://127.0.0.1:1337/'); 2. node hello_world.js 3. Browse to http://127.0.0.1:1337 in chrome. 4. Bask in the glory of how much easier than that was than Ruby and Rails has ever been.
  7. 3/5/12 3:06 PM nodejs - step 1 Page 7 of

    9 file:///Users/scottmotte/code/javascript/node_step_1/presentation/presentation/index.html hello_world.coffee in coffeescript 0. npm install coffee-script 1. Create file called hello_world.coffee with the following code. http = require("http") http.createServer((req, res) -> res.writeHead 200, "Content-Type": "text/plain" res.end "Hello World\n" ).listen 1337, "127.0.0.1" console.log "Server running at http://127.0.0.1:1337/" 2. coffee hello_world.coffee 3. Browse to http://127.0.0.1:1337 in chrome.
  8. 3/5/12 3:06 PM nodejs - step 1 Page 8 of

    9 file:///Users/scottmotte/code/javascript/node_step_1/presentation/presentation/index.html 4. Enjoy writing your node apps in coffeescript from here forward.
  9. 3/5/12 3:06 PM nodejs - step 1 Page 9 of

    9 file:///Users/scottmotte/code/javascript/node_step_1/presentation/presentation/index.html Next Time NPM - Node Package Manager Deploying to Heroku Frameworks like Express.js Socket.io jQuery in node