diff --git a/Gruntfile.coffee b/Gruntfile.coffee index da2fff933a5ed2b56849d30c36f8c5216e962a79..08544110789edd8230e50941c4ff4f8d2e8db38e 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -34,7 +34,7 @@ module.exports = (grunt) -> livereload: options: - port: process.env.PORT || 80 + port: process.env.PORT || 3000 # Change hostname to '0.0.0.0' to access # the server from outside. hostname: '0.0.0.0' diff --git a/outline.txt b/outline.txt index 385c2e5b7bc26134ea156a5f5b57c8c4d9948a70..5232ba83ecd0304a65652225332ef60a3877eea8 100644 --- a/outline.txt +++ b/outline.txt @@ -10,10 +10,12 @@ var requestHandler = function (request, response) { } http.createServer(requestHandler).listen(1337, '127.0.0.1'); ``` +- important background stuff about node - can handle all kinds of requests, GET, POST etc via 'request' object thats passed to the handler - plenty of 'modules' that make this less of a pain - so simple!! + 1.5) outline of nodejs - v8 engine that compile/interprets js - high performance http parser (in C) @@ -41,6 +43,7 @@ https://www.youtube.com/watch?v=hWhMKalEicY it will be enqueued, and node will get around to handling that file eventually - dont do cpu heavy tasks in node +s 4) javascript part, callback-based scheme - http://vimeo.com/111122950 around 5:30 diff --git a/pics/who_uses.png b/pics/who_uses.png new file mode 100644 index 0000000000000000000000000000000000000000..81224a3c69e738b9c036de547af19e9071479812 Binary files /dev/null and b/pics/who_uses.png differ diff --git a/simple-server.js b/simple-server.js index 553a0a4748513813f72e746b830cb1316d9470af..8cf3ba2a2c4be82c02250ca38bd4a34cf233779c 100644 --- a/simple-server.js +++ b/simple-server.js @@ -1,5 +1,5 @@ var http = require('http'); -var requestHandler = function (request, response) { +function requestHandler(request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello CSE 333\n'); } diff --git a/slides/how-is-node-put-together.md b/slides/how-is-node-put-together.md new file mode 100644 index 0000000000000000000000000000000000000000..beb8c3698ab89a5c0a3f34388813832f2f0f79f4 --- /dev/null +++ b/slides/how-is-node-put-together.md @@ -0,0 +1,5 @@ +## How is node put together? + +Three main components: +* Google V8 engine that compiles/optimizes Javascript +* High performance http parser diff --git a/slides/list.json b/slides/list.json index c0c44d22dc02e5f2b4399129606146e7c696c628..bc7901e86ddcf8cd8801fb62bf78113f16e7384a 100644 --- a/slides/list.json +++ b/slides/list.json @@ -2,11 +2,8 @@ "nodejs.md", "who-is-this-kid.md", "outline.md", - "what-even-is-node.md", - "problem-background.md", - "javascript-to-the-rescue.md", - "javascript-ex1.md", - "javascript-ex2.md", - "anaymous-callbacks.md", - "event-loop.md" + "why-node-is-awesome.md", + "why-node-is-awesome-pt-2.md", + "who-uses-node.md", + "how-is-node-put-together.md" ] \ No newline at end of file diff --git a/slides/outline.md b/slides/outline.md index b1caef93614081f19409b99d51f5eab03451708e..e5236cca5f967bdac6fd956674a6860cf6f52e27 100644 --- a/slides/outline.md +++ b/slides/outline.md @@ -1,9 +1,7 @@ ## Outline -1. What even *is* node? - * What even ***is*** javascript?? -2. Awesome stuff about node -3. Disadvantages of node -4. Who uses nodejs in production? -5. Live demo D: - * *mandatory participation* \ No newline at end of file +1. Why node is awesome +2. Nodejs architecture overview +3. V8, c++, and optimizing oh my +4. Why javascript? (aka all glory to the event loop) +5. Recap + takeaways diff --git a/slides/who-uses-node.md b/slides/who-uses-node.md new file mode 100644 index 0000000000000000000000000000000000000000..89c4f45795bf7b76b68a71fa9caf2f6aae27e769 --- /dev/null +++ b/slides/who-uses-node.md @@ -0,0 +1,7 @@ +## Who uses node? + +<img src="pics/who_uses.png"> + +Uber, Yahoo, Microsoft, Ebay, Cloud9 IDE, +Dow Jones, LinkedIn, The New York Times, +PayPal diff --git a/slides/why-node-is-awesome-pt-2.md b/slides/why-node-is-awesome-pt-2.md new file mode 100644 index 0000000000000000000000000000000000000000..2133390ffc091c80c9cb3998b8d9d7b76180455b --- /dev/null +++ b/slides/why-node-is-awesome-pt-2.md @@ -0,0 +1,6 @@ +## Why node is awesome pt 2 + +* Very simple to set up a server +* It's Just Javascript +* Plenty of composable modules +* Very active development (the New Hotness) \ No newline at end of file diff --git a/slides/why-node-is-awesome.md b/slides/why-node-is-awesome.md new file mode 100644 index 0000000000000000000000000000000000000000..0e86d80f0c00f990a6fc42356d5cbad3f540d5cc --- /dev/null +++ b/slides/why-node-is-awesome.md @@ -0,0 +1,13 @@ +## Why node is awesome + +```javascript +// simple-server.js +var http = require('http'); + +function requestHandler(request, response) { + response.writeHead(200, {'Content-Type': 'text/plain'}); + response.end('Hello CSE 333\n'); +} + +http.createServer(requestHandler).listen(1337, '127.0.0.1'); +``` diff --git a/sys-example.js b/sys-example.js new file mode 100644 index 0000000000000000000000000000000000000000..da71c58b8e3025e766708be54fe81293a219acbe --- /dev/null +++ b/sys-example.js @@ -0,0 +1,18 @@ +var http = require('http'); +var sys = require('sys'); +var spawn = require('child_process').spawn; +// var ls = spawn('ls', ['-lh', '/']); + +// ls.stdout.on('data', function(data) { +// console.log(data.toString('ascii')); +// }) + +http.createServer(function (req, res) { + var ls = spawn('ls', ['-lh', '/']); + ls.stdout.on('data', function(data) { + // console.log(data.toString('ascii')); + res.writeHead(200, {'Content-Type': 'text/plain'}); + res.end(data.toString('ascii')); + }) +}).listen(3555, '127.0.0.1'); +