Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed docco err

  • Loading branch information...
commit 64dba4550d5bfa39c5d80c240194ff630e6fe93b 1 parent 8ed7928
@jaigouk authored
Showing with 1,330 additions and 116 deletions.
  1. +11 −6 coffee_files/028_classes_prototype_closure.coffee
  2. +1 −1  docs/000_intro.html
  3. +10 −3 docs/001_http.html
  4. +16 −3 docs/002_child_process.html
  5. +22 −5 docs/003_pump.html
  6. +23 −1 docs/004_step.html
  7. +26 −2 docs/005_chat.html
  8. +36 −3 docs/006_socket_chat.html
  9. +21 −2 docs/007_socket.io_chat.html
  10. +8 −1 docs/008_0_connect.html
  11. +12 −2 docs/008_1_serve-js.html
  12. +12 −1 docs/008_2_log-it.html
  13. +23 −3 docs/009_express.html
  14. +36 −4 docs/010_0_express.html
  15. +20 −1 docs/010_1_products.html
  16. +54 −2 docs/011_0_express.html
  17. +36 −1 docs/011_1_products.html
  18. +85 −4 docs/012_0_file_upload.html
  19. +11 −1 docs/012_1_photos.html
  20. +36 −1 docs/012_2_products.html
  21. +113 −3 docs/013_0_auth.html
  22. +11 −1 docs/013_1_photos.html
  23. +36 −1 docs/013_2_products.html
  24. +22 −1 docs/013_3_users.html
  25. +9 −1 docs/014_0_tools.html
  26. +3 −1 docs/015_deploy.html
  27. +3 −1 docs/016_coffeescript.html
  28. +29 −6 docs/017_0_modules.html
  29. +10 −2 docs/017_1_test_modules.html
  30. +141 −4 docs/018_0_mongoose.html
  31. +11 −1 docs/018_1_photos.html
  32. +18 −2 docs/018_2_products.html
  33. +27 −4 docs/018_3_users.html
  34. +41 −3 docs/019_async_interation.html
  35. +29 −3 docs/020_tdd.html
  36. +54 −2 docs/021_mongoose_update.html
  37. +28 −1 docs/022_bundling.html
  38. +30 −3 docs/023_express_resources.html
  39. +11 −1 docs/024_0_benchmark.html
  40. +28 −1 docs/024_1_test.html
  41. +15 −1 docs/024_2_statistics.html
  42. +18 −1 docs/025_nginx.html
  43. +31 −3 docs/026_0_everyauth.html
  44. +35 −1 docs/026_1_users.html
  45. +24 −2 docs/027_0_kue.html
  46. +12 −2 docs/027_1_kue_consumer.html
  47. +42 −17 docs/028_classes_prototype_closure.html
View
17 coffee_files/028_classes_prototype_closure.coffee
@@ -1,25 +1,30 @@
# # classes, prototypes and closures
-#***
-# * [Kue](http://learnboost.github.com/kue/)
-#
-#***
+# The souce code bellow works almost same except for the encapsulation of @a, @b, @coalesce
+#
+#`class Adder`
#
-
-#`class Adder`
#` constructor: (@a, @b)->`
#
#` coalesce: ->`
+#
#` unless @a then @a = 0`
+#
#` unless @b then @b = 0`
#
#` add: ->`
+#
#` @coalesce()`
+#
#` console.log (@a + @b).toString()`
#
#` a1 = new Adder(2,4)`
+#
#` console.log a1.b`
+#
#` a1.a = 5`
+#
#` console.log a1.a`
+#
#` a1.add()`
EventEmitter = require("events").EventEmitter
View
2  docs/000_intro.html
@@ -91,4 +91,4 @@
<li><a href="http://maccman.github.com/spine/">Spine</a> </li>
<li><a href="http://maccman.github.com/spine.tutorials/">Spine Tutorials</a> </li>
<li><a href="https://github.com/maccman">spine related awesome projects by maccman</a> </li>
-</ul> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+</ul> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
13 docs/001_http.html
@@ -22,13 +22,20 @@
<p>'connection': 'keep-alive',</p>
-<p>'accept': '<em>/</em>' }`</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>response.writeHead(statusCode, [reasonPhrase], [headers])</h3>
+<p>'accept': '<em>/</em>' }`</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">http = </span><span class="nx">require</span> <span class="s1">&#39;http&#39;</span>
+ </pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>response.writeHead(statusCode, [reasonPhrase], [headers])</h3>
<p>This method must only be called once on a message and it must be called before response.end() is called.
-If you call response.write() or response.end() before calling this, the implicit/mutable headers will be calculated and call this function for you.</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h3>server.listen(port, [hostname], [callback])</h3>
+If you call response.write() or response.end() before calling this, the implicit/mutable headers will be calculated and call this function for you.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">server = </span><span class="nx">http</span><span class="p">.</span><span class="nx">createServer</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s1">&#39;new req&#39;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">writeHead</span> <span class="mi">200</span><span class="p">,</span>
+ <span class="s1">&#39;Content-Type&#39;</span><span class="o">:</span> <span class="s1">&#39;text/plain&#39;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">end</span> <span class="s1">&#39;Hello World&#39;</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h3>server.listen(port, [hostname], [callback])</h3>
<p>Begin accepting connections on the specified port and hostname. If the hostname is omitted, the server will accept connections directed to any IPv4 address (INADDR_ANY).</p>
<p>To listen to a unix socket, supply a filename instead of port and hostname.</p>
-<p>This function is asynchronous. The last parameter callback will be called when the server has been bound to the port.</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+<p>This function is asynchronous. The last parameter callback will be called when the server has been bound to the port.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">server</span><span class="p">.</span><span class="nx">listen</span> <span class="mi">4000</span><span class="p">,</span> <span class="s1">&#39;localhost&#39;</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
19 docs/002_child_process.html
@@ -15,9 +15,22 @@
To create a child process use require('child_process').spawn().
Child processes always have three streams associated with them. child.stdin, child.stdout, and child.stderr.</p>
-<p>ChildProcess is an EventEmitter.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>spawn</h3>
+<p>ChildProcess is an EventEmitter.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">http = </span><span class="nx">require</span> <span class="s1">&#39;http&#39;</span>
+<span class="p">{</span><span class="nx">spawn</span><span class="p">}</span> <span class="o">=</span> <span class="nx">require</span> <span class="s1">&#39;child_process&#39;</span>
-<p>Launches a new process with the given command, with command line arguments in args. If omitted, args defaults to an empty Array.</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h3>child.kill(signal='SIGTERM')</h3>
+<span class="nv">server = </span><span class="nx">http</span><span class="p">.</span><span class="nx">createServer</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">writeHead</span> <span class="mi">200</span><span class="p">,</span>
+ <span class="s1">&#39;Content-Type&#39;</span><span class="o">:</span> <span class="s1">&#39;text/plain&#39;</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>spawn</h3>
+
+<p>Launches a new process with the given command, with command line arguments in args. If omitted, args defaults to an empty Array.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">tail_child = </span><span class="nx">spawn</span> <span class="s1">&#39;tail&#39;</span> <span class="p">,</span> <span class="p">[</span><span class="s1">&#39;-f&#39;</span><span class="p">,</span> <span class="s1">&#39;/var/log/system.log&#39;</span><span class="p">]</span> </pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h3>child.kill(signal='SIGTERM')</h3>
<p>Send a signal to the child process. If no argument is given, the process will be sent 'SIGTERM'. See signal(7) for a list of available signals. <br />
-<strong>Note that while the function is called kill, the signal delivered to the child process may not actually kill it. kill really just sends a signal to a process.</strong></p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>This res.write line may cause a problem</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+<strong>Note that while the function is called kill, the signal delivered to the child process may not actually kill it. kill really just sends a signal to a process.</strong></p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">req</span><span class="p">.</span><span class="nx">connection</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;end&#39;</span><span class="p">,</span> <span class="o">-&gt;</span>
+ <span class="nx">tail_child</span><span class="p">.</span><span class="nx">kill</span><span class="p">()</span>
+
+ <span class="nx">tail_child</span><span class="p">.</span><span class="nx">stdout</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="nf">(data) -&gt;</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="nx">data</span><span class="p">.</span><span class="nx">toString</span><span class="p">()</span> </pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>This res.write line may cause a problem</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">res</span><span class="p">.</span><span class="nx">write</span> <span class="nx">data</span>
+
+<span class="nx">server</span><span class="p">.</span><span class="nx">listen</span> <span class="mi">4000</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
27 docs/003_pump.html
@@ -10,11 +10,13 @@
<hr />
-<h3>Streams</h3> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>A stream is an abstract interface implemented by various objects in Node. For example a request to an HTTP server is a stream, as is stdout. </p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p><strong>Streams are readable, writable, or both.</strong> All streams are instances of EventEmitter.</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <h3>File System</h3>
+<h3>Streams</h3> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>A stream is an abstract interface implemented by various objects in Node. For example a request to an HTTP server is a stream, as is stdout. </p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p><strong>Streams are readable, writable, or both.</strong> All streams are instances of EventEmitter.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">http = </span><span class="nx">require</span> <span class="s1">&#39;http&#39;</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <h3>File System</h3>
<p>File I/O is provided by simple wrappers around standard POSIX functions. To use this module do require('fs'). All the methods have asynchronous and synchronous forms.</p>
-<p>The asynchronous form always take a completion callback as its last argument. The arguments passed to the completion callback depend on the method, but the first argument is always reserved for an exception. If the operation was completed successfully, then the first argument will be null or undefined.</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <ul>
+<p>The asynchronous form always take a completion callback as its last argument. The arguments passed to the completion callback depend on the method, but the first argument is always reserved for an exception. If the operation was completed successfully, then the first argument will be null or undefined.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">fs = </span><span class="nx">require</span> <span class="s1">&#39;fs&#39;</span>
+<span class="nv">util = </span><span class="nx">require</span> <span class="s1">&#39;util&#39;</span>
+<span class="nv">file_path = </span><span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/asset/cat.jpg&#39;</span> </pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <ul>
<li><p>fs.stat(path, [callback])
Asynchronous stat(2). The callback gets two arguments (err, stats) where stats is a <code>fs.Stats</code> object. </p></li>
<li><p>fs.Stats
@@ -25,8 +27,23 @@
stats.isSymbolicLink() (only valid with fs.lstat()),
stats.isFIFO(),
stats.isSocket(), </p></li>
-</ul> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Returns a new ReadStream object
-readStream is a Readable Stream. </p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <h3>util.pump</h3>
+</ul> </td> <td class="code"> <div class="highlight"><pre><span class="nx">fs</span><span class="p">.</span><span class="nx">stat</span> <span class="nx">file_path</span><span class="p">,</span> <span class="nf">(err, stat) -&gt;</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="nx">file_path</span>
+ <span class="k">throw</span> <span class="nx">err</span> <span class="k">if</span> <span class="nx">err</span>
+
+
+ <span class="nv">server = </span><span class="nx">http</span><span class="p">.</span><span class="nx">createServer</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">writeHead</span> <span class="mi">200</span><span class="p">,</span>
+ <span class="s1">&#39;Content-Type&#39;</span><span class="o">:</span> <span class="s1">&#39;image/jpeg&#39;</span>
+ <span class="s1">&#39;Content-Length&#39;</span><span class="o">:</span> <span class="nx">stat</span><span class="p">.</span><span class="nx">size</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Returns a new ReadStream object
+readStream is a Readable Stream. </p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">readStream = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">createReadStream</span><span class="p">(</span><span class="nx">file_path</span><span class="p">)</span> </pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <h3>util.pump</h3>
<p><strong>Experimental</strong>
-Read the data from readableStream and send it to the writableStream. When writableStream.write(data) returns false readableStream will be paused until the drain event occurs on the writableStream. callback gets an error as its only argument and is called when writableStream is closed or when an error occurs. </p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+Read the data from readableStream and send it to the writableStream. When writableStream.write(data) returns false readableStream will be paused until the drain event occurs on the writableStream. callback gets an error as its only argument and is called when writableStream is closed or when an error occurs. </p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">util</span><span class="p">.</span><span class="nx">pump</span> <span class="nx">readStream</span><span class="p">,</span> <span class="nx">res</span><span class="p">,</span> <span class="nf">(err) -&gt;</span>
+ <span class="k">throw</span> <span class="nx">err</span> <span class="k">if</span> <span class="nx">err</span>
+
+
+ <span class="nx">server</span><span class="p">.</span><span class="nx">listen</span> <span class="mi">4000</span>
+
+
+</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
24 docs/004_step.html
@@ -6,4 +6,26 @@
<li><a href="https://github.com/creationix/step">Step </a> - An async control-flow library that makes stepping through logic easy.</li>
</ul>
-<hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>The step library exports a single function called Step. It accepts any number of functions as arguments and runs them in serial order using the passed in this context as the callback to the next step.</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+<hr /> </td> <td class="code"> <div class="highlight"><pre><span class="nv">http = </span><span class="nx">require</span> <span class="s1">&#39;http&#39;</span>
+<span class="nv">fs = </span><span class="nx">require</span> <span class="s1">&#39;fs&#39;</span>
+<span class="nv">step = </span><span class="nx">require</span> <span class="s1">&#39;step&#39;</span>
+
+<span class="nv">file_path = </span><span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/asset/cat.jpg&#39;</span>
+<span class="nv">file_size = </span><span class="kc">null</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>The step library exports a single function called Step. It accepts any number of functions as arguments and runs them in serial order using the passed in this context as the callback to the next step.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">step</span> <span class="nv">get_file_size = </span><span class="o">-&gt;</span>
+ <span class="nx">fs</span><span class="p">.</span><span class="nx">stat</span> <span class="nx">file_path</span><span class="p">,</span> <span class="k">this</span>
+<span class="p">,</span> <span class="nv">store_file_size = </span><span class="nf">(err, stat) -&gt;</span>
+ <span class="k">throw</span> <span class="nx">err</span> <span class="k">if</span> <span class="nx">err</span>
+ <span class="nv">file_size = </span><span class="nx">stat</span><span class="p">.</span><span class="nx">size</span>
+ <span class="k">this</span>
+<span class="p">,</span> <span class="nv">read_file_into_memory = </span><span class="nf">() -&gt;</span>
+ <span class="nx">fs</span><span class="p">.</span><span class="nx">readFile</span> <span class="nx">file_path</span><span class="p">,</span> <span class="k">this</span>
+<span class="p">,</span> <span class="nv">create_server = </span><span class="nf">(err, file_content) -&gt;</span>
+ <span class="k">throw</span> <span class="nx">err</span> <span class="k">if</span> <span class="nx">err</span>
+ <span class="nx">http</span><span class="p">.</span><span class="nx">createServer</span> <span class="nf">(request, response) -&gt;</span>
+ <span class="nx">response</span><span class="p">.</span><span class="nx">writeHead</span> <span class="mi">200</span><span class="p">,</span>
+ <span class="s1">&#39;Content-Type&#39;</span><span class="o">:</span> <span class="s1">&#39;image/jpeg&#39;</span>
+ <span class="s1">&#39;Content-Length&#39;</span><span class="o">:</span> <span class="nx">file_size</span>
+ <span class="nx">response</span><span class="p">.</span><span class="nx">end</span> <span class="nx">file_content</span>
+ <span class="p">.</span><span class="nx">listen</span> <span class="mi">4000</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
28 docs/005_chat.html
@@ -7,10 +7,34 @@
<li><a href="https://github.com/pgte/carrier">Carrier</a> - Evented stream line reader for node.js </li>
</ul>
-<hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>net</h3>
+<hr /> </td> <td class="code"> <div class="highlight"><pre><span class="nv">net = </span><span class="nx">require</span> <span class="s1">&#39;net&#39;</span>
+<span class="nv">carrier = </span><span class="nx">require</span> <span class="s1">&#39;carrier&#39;</span>
+
+<span class="nv">connections = </span><span class="p">[]</span>
+ </pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>net</h3>
<p>The net module provides you with an asynchronous network wrapper. It contains methods for creating both servers and clients (called streams). You can include this module with require("net");</p>
<h3>net.createServer([options], [connectionListener])</h3>
-<p>Creates a new TCP server. The connectionListener argument is automatically set as a listener for the 'connection' event.</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+<p>Creates a new TCP server. The connectionListener argument is automatically set as a listener for the 'connection' event.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">net</span><span class="p">.</span><span class="nx">createServer</span> <span class="nf">(conn) -&gt;</span>
+ <span class="nx">connections</span><span class="p">.</span><span class="nx">push</span> <span class="nx">conn</span>
+
+ <span class="nx">conn</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;close&#39;</span><span class="p">,</span> <span class="nf">() -&gt;</span>
+ <span class="nv">pos = </span><span class="nx">connections</span><span class="p">.</span><span class="nx">indexOf</span> <span class="nx">conn</span>
+ <span class="nx">connections</span><span class="p">.</span><span class="nx">splice</span> <span class="nx">pos</span><span class="p">,</span> <span class="mi">1</span> <span class="k">if</span> <span class="nx">pos</span> <span class="o">&gt;=</span> <span class="mi">0</span>
+
+ <span class="nx">conn</span><span class="p">.</span><span class="nx">write</span> <span class="s1">&#39;Hello, welcome to this chat server!\n&#39;</span>
+ <span class="nx">conn</span><span class="p">.</span><span class="nx">write</span> <span class="s1">&#39;Please input your user name: \n&#39;</span>
+ <span class="nv">username = </span><span class="s1">&#39;&#39;</span>
+ <span class="nx">carrier</span><span class="p">.</span><span class="nx">carry</span> <span class="nx">conn</span><span class="p">,</span> <span class="nf">(line) -&gt;</span>
+ <span class="k">if</span> <span class="o">not</span> <span class="nx">username</span>
+ <span class="nv">username = </span><span class="nx">line</span>
+ <span class="nx">conn</span><span class="p">.</span><span class="nx">write</span> <span class="s2">&quot;Hello #{username}! \n&quot;</span>
+ <span class="nx">conn</span><span class="p">.</span><span class="nx">end</span><span class="p">()</span> <span class="k">if</span> <span class="nx">line</span> <span class="o">is</span> <span class="s1">&#39;quit&#39;</span>
+ <span class="k">for</span> <span class="nx">one_connection</span> <span class="k">in</span> <span class="nx">connections</span>
+ <span class="nx">one_connection</span><span class="p">.</span><span class="nx">write</span><span class="p">(</span><span class="s2">&quot;#{username}: #{line}\n&quot;</span><span class="p">)</span>
+
+<span class="p">.</span><span class="nx">listen</span> <span class="mi">4000</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
39 docs/006_socket_chat.html
@@ -9,7 +9,16 @@
<li><a href="https://github.com/ncr/node.ws.js">node.ws.js</a> - Basic Web Sockets Server for node.js with similar interface to tcp.createServer(...)</li>
</ul>
-<hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>fs.createReadStream(path, [options])</h3>
+<hr /> </td> <td class="code"> <div class="highlight"><pre><span class="nv">http = </span><span class="nx">require</span> <span class="s1">&#39;http&#39;</span>
+<span class="nv">fs = </span><span class="nx">require</span> <span class="s1">&#39;fs&#39;</span>
+<span class="nv">util = </span><span class="nx">require</span> <span class="s1">&#39;util&#39;</span>
+<span class="nv">ws = </span><span class="nx">require</span> <span class="s1">&#39;./asset/ws.js&#39;</span>
+
+<span class="nv">clients = </span><span class="p">[]</span>
+
+<span class="nx">http</span><span class="p">.</span><span class="nx">createServer</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">writeHead</span> <span class="mi">200</span><span class="p">,</span>
+ <span class="s1">&#39;Content-Type&#39;</span><span class="o">:</span> <span class="s1">&#39;text/html&#39;</span> </pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>fs.createReadStream(path, [options])</h3>
<p>Returns a new ReadStream object (See Readable Stream).</p>
@@ -27,10 +36,34 @@
<p>bufferSize: 64 * 1024`</p>
<p>}
-````</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>options can include start and end values to read a range of bytes from the file instead of the entire file. Both start and end are inclusive and start at 0.</p>
+````</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>options can include start and end values to read a range of bytes from the file instead of the entire file. Both start and end are inclusive and start at 0.</p>
<p>An example to read the last 10 bytes of a file which is 100 bytes long:</p>
<p><code>
fs.createReadStream('sample.txt', {start: 90, end: 99});
-</code></p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+</code></p> </td> <td class="code"> <div class="highlight"><pre> <span class="nv">rs = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">createReadStream</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/asset/template.html&#39;</span>
+ <span class="nx">util</span><span class="p">.</span><span class="nx">pump</span><span class="p">(</span><span class="nx">rs</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span>
+
+<span class="p">.</span><span class="nx">listen</span> <span class="mi">4000</span>
+
+<span class="nx">ws</span><span class="p">.</span><span class="nx">createServer</span> <span class="nf">(websocket) -&gt;</span>
+ <span class="nv">username = </span><span class="s1">&#39;&#39;</span>
+ <span class="nx">websocket</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;connect&#39;</span><span class="p">,</span> <span class="nf">(resource) -&gt;</span>
+ <span class="nx">clients</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">websocket</span><span class="p">)</span>
+ <span class="nx">websocket</span><span class="p">.</span><span class="nx">write</span><span class="p">(</span><span class="s1">&#39;Welcome to this chat server!&#39;</span><span class="p">)</span>
+ <span class="nx">websocket</span><span class="p">.</span><span class="nx">write</span><span class="p">(</span><span class="s1">&#39;Please input your username.&#39;</span><span class="p">)</span>
+ <span class="nx">websocket</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="nf">(data) -&gt;</span>
+ <span class="nx">unless</span> <span class="nx">username</span>
+ <span class="nv">username = </span><span class="nx">data</span><span class="p">.</span><span class="nx">toString</span><span class="p">()</span>
+ <span class="nx">websocket</span><span class="p">.</span><span class="nx">write</span> <span class="s2">&quot;Welcome, #{username}!&quot;</span>
+ <span class="nv">feedback = </span><span class="s2">&quot;#{username} said: #{data.toString()}&quot;</span>
+ <span class="nx">client</span><span class="p">.</span><span class="nx">write</span> <span class="nx">feedback</span> <span class="k">for</span> <span class="nx">client</span> <span class="k">in</span> <span class="nx">clients</span>
+
+ <span class="nx">websocket</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;close&#39;</span><span class="p">,</span> <span class="nf">() -&gt;</span>
+ <span class="nv">pos = </span><span class="nx">clients</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">websocket</span><span class="p">)</span>
+ <span class="nx">clients</span><span class="p">.</span><span class="nx">splice</span> <span class="nx">pos</span><span class="p">,</span> <span class="mi">1</span> <span class="k">if</span> <span class="nx">pos</span> <span class="o">&gt;=</span> <span class="mi">0</span>
+
+<span class="p">.</span><span class="nx">listen</span> <span class="mi">8080</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
23 docs/007_socket.io_chat.html
@@ -11,7 +11,19 @@
<li><a href="http://camp.nodejs.org/videos/session-06_socketio_workshop-guillermo_rauch.html">camp.nodejs 2010 (video)</a></li>
</ul>
-<hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>Socket.io</h3> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h3>Namespce</h3>
+<hr /> </td> <td class="code"> <div class="highlight"><pre><span class="nv">http = </span><span class="nx">require</span> <span class="s1">&#39;http&#39;</span>
+<span class="nv">fs = </span><span class="nx">require</span> <span class="s1">&#39;fs&#39;</span>
+<span class="nv">util = </span><span class="nx">require</span> <span class="s1">&#39;util&#39;</span>
+
+<span class="nv">server = </span><span class="nx">http</span><span class="p">.</span><span class="nx">createServer</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">writeHead</span> <span class="mi">200</span><span class="p">,</span>
+ <span class="s1">&#39;Content-Type&#39;</span><span class="o">:</span> <span class="s1">&#39;text/html&#39;</span>
+ <span class="nv">rs = </span><span class="nx">fs</span><span class="p">.</span><span class="nx">createReadStream</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/asset/template2.html&#39;</span>
+ <span class="nx">util</span><span class="p">.</span><span class="nx">pump</span><span class="p">(</span><span class="nx">rs</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span>
+<span class="nx">server</span><span class="p">.</span><span class="nx">listen</span> <span class="mi">4000</span> </pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h3>Socket.io</h3> </td> <td class="code"> <div class="highlight"><pre>
+<span class="nv">io = </span><span class="nx">require</span><span class="p">(</span><span class="s1">&#39;socket.io&#39;</span><span class="p">).</span><span class="nx">listen</span><span class="p">(</span><span class="nx">server</span><span class="p">)</span>
+<span class="nx">io</span><span class="p">.</span><span class="nx">sockets</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;connection&#39;</span><span class="p">,</span> <span class="nf">(socket) -&gt;</span>
+ <span class="nv">username = </span><span class="s1">&#39;&#39;</span> </pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h3>Namespce</h3>
<p><code>
socket.on('item')
@@ -20,4 +32,11 @@
<p>Socket.IO now gives you one <code>Socket</code> per namespace you define.
Each "sub-socket" or "namespace" has the same characteristics of any other Socket, but socket.io does the heavylifting of splitting the messages in a very lightweight and performant way. This technique is specially necessary for non-WebSocket transports, as they're usually associated with more than one connection. </p>
-<p>Custom events allow you to simplify your code, and their implementation adds no overhead to the protocol. This means that if you don't use them, not much will change.</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>If you pass parameters, those will be automatically encoded and decoded in JSON for you. In addition, you can pass data around: </p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+<p>Custom events allow you to simplify your code, and their implementation adds no overhead to the protocol. This means that if you don't use them, not much will change.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>If you pass parameters, those will be automatically encoded and decoded in JSON for you. In addition, you can pass data around: </p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">socket</span><span class="p">.</span><span class="kc">on</span> <span class="s1">&#39;message&#39;</span><span class="p">,</span> <span class="nf">(msg) -&gt;</span>
+ <span class="k">if</span> <span class="o">not</span> <span class="nx">username</span>
+ <span class="nv">username = </span><span class="nx">msg</span>
+ <span class="nx">socket</span><span class="p">.</span><span class="nx">emit</span> <span class="s1">&#39;message&#39;</span><span class="p">,</span> <span class="s2">&quot;Welcome #{username}!\n&quot;</span>
+ <span class="k">else</span>
+ <span class="nx">io</span><span class="p">.</span><span class="nx">sockets</span><span class="p">.</span><span class="nx">emit</span> <span class="s1">&#39;message&#39;</span><span class="p">,</span> <span class="s2">&quot;#{username} sent&gt; #{msg}&quot;</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
9 docs/008_0_connect.html
@@ -23,4 +23,11 @@
<p><code>$ npm install qs mime</code></p>
-<p>And this solved the problem.</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p><code>http://localhost:4000//Users/jaigouk/.vimrc</code> works :D</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+<p>And this solved the problem.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">connect = </span><span class="nx">require</span> <span class="s1">&#39;connect&#39;</span>
+
+<span class="nx">connect</span><span class="p">.</span><span class="nx">createServer</span><span class="p">(</span><span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./008_2_log-it&#39;</span><span class="p">)()</span>
+<span class="p">,</span> <span class="nx">require</span><span class="p">(</span><span class="s1">&#39;./008_1_serve-js&#39;</span><span class="p">)())</span>
+<span class="p">.</span><span class="nx">listen</span> <span class="mi">4000</span>
+ </pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p><code>http://localhost:4000//Users/jaigouk/.vimrc</code> works :D</p> </td> <td class="code"> <div class="highlight"><pre>
+
+</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
14 docs/008_1_serve-js.html
@@ -9,6 +9,16 @@
<li><a href="https://github.com/senchalabs/connect/wiki">Connect Milddleware list</a></li>
</ul>
-<hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>data is buffer.</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>just move on.
+<hr /> </td> <td class="code"> <div class="highlight"><pre><span class="nv">fs = </span><span class="nx">require</span> <span class="s1">&#39;fs&#39;</span>
+
+<span class="nv">module.exports = </span><span class="o">-&gt;</span>
+ <span class="nf">(req, res, next) -&gt;</span>
+
+ <span class="nx">fs</span><span class="p">.</span><span class="nx">readFile</span> <span class="nx">req</span><span class="p">.</span><span class="nx">url</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="nf">(err, data) -&gt;</span> </pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>data is buffer.</p> </td> <td class="code"> <div class="highlight"><pre> </pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>just move on.
some errors like getting a favicon <br />
-next if err </p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+next if err </p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="nx">err</span> <span class="k">if</span> <span class="nx">err</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">writeHead</span> <span class="mi">200</span><span class="p">,</span>
+ <span class="s1">&#39;Content-Type&#39;</span><span class="o">:</span> <span class="s1">&#39;application/javascript&#39;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">end</span> <span class="nx">data</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
13 docs/008_2_log-it.html
@@ -9,4 +9,15 @@
<li><a href="https://github.com/senchalabs/connect/wiki">Connect Milddleware list</a></li>
</ul>
-<hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h1>Don't forget to call next()</h1> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+<hr /> </td> <td class="code"> <div class="highlight"><pre><span class="nv">util = </span><span class="nx">require</span> <span class="s1">&#39;util&#39;</span>
+<span class="nv">module.exports = </span><span class="o">-&gt;</span>
+ <span class="nv">counter = </span><span class="mi">0</span>
+ <span class="nf">(req, res, next) -&gt;</span>
+ <span class="nv">writeHead = </span><span class="nx">res</span><span class="p">.</span><span class="nx">writeHead</span>
+ <span class="nx">counter</span> <span class="o">+=</span> <span class="mi">1</span>
+ <span class="nv">res.writeHead = </span><span class="nf">(code, headers) -&gt;</span>
+ <span class="nv">res.writeHead = </span><span class="nx">writeHead</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s2">&quot;Response: #{counter} #{code} #{util.inspect(headers)}&quot;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">writeHead</span><span class="p">(</span><span class="nx">code</span><span class="p">,</span> <span class="nx">headers</span><span class="p">)</span> </pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h1>Don't forget to call next()</h1> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">next</span><span class="p">()</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
26 docs/009_express.html
@@ -9,8 +9,28 @@
<li><a href="https://github.com/visionmedia/jade">Jade</a> </li>
</ul>
-<hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h1>Middleware</h1>
+<hr /> </td> <td class="code"> <div class="highlight"><pre><span class="nv">express= </span><span class="nx">require</span> <span class="s1">&#39;express&#39;</span>
-<p>Middleware ordering is important, when Connect receives a request the first middleware we pass to createServer() or use() is executed with three parameters, request, response, and a callback function usually named next. When next() is invoked the second middleware will then have it’s turn and so on. This is important to note because many middleware depend on each other, for example methodOverride() checks req.body.method for the HTTP method override, however bodyParser() parses the request body and populates req.body.</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h1>Route Middleware</h1>
+<span class="nv">app = </span><span class="nx">express</span><span class="p">.</span><span class="nx">createServer</span><span class="p">()</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <h1>Middleware</h1>
-<p>To keep things DRY and to increase readability we can apply this logic within a middleware. Multiple route middleware can be applied, and will be executed sequentially to apply further logic such as restricting access to a user account. Keeping in mind that middleware are simply functions, we can define function that returns the middleware in order to create a more expressive and flexible solution</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+<p>Middleware ordering is important, when Connect receives a request the first middleware we pass to createServer() or use() is executed with three parameters, request, response, and a callback function usually named next. When next() is invoked the second middleware will then have it’s turn and so on. This is important to note because many middleware depend on each other, for example methodOverride() checks req.body.method for the HTTP method override, however bodyParser() parses the request body and populates req.body.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">app</span><span class="p">.</span><span class="nx">configure</span> <span class="s1">&#39;development&#39;</span><span class="p">,</span> <span class="nf">() -&gt;</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">logger</span><span class="p">()</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">errorHandler</span>
+ <span class="nv">dumpExceptions: </span><span class="kc">true</span><span class="p">,</span>
+ <span class="nv">showStack: </span><span class="kc">true</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">configure</span> <span class="s1">&#39;production&#39;</span><span class="p">,</span> <span class="nf">() -&gt;</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">logger</span><span class="p">()</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">errorHandler</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">set</span> <span class="s1">&#39;views&#39;</span><span class="p">,</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/views_009&#39;</span>
+<span class="nx">app</span><span class="p">.</span><span class="nx">set</span> <span class="s1">&#39;view engine&#39;</span><span class="p">,</span> <span class="s1">&#39;jade&#39;</span>
+<span class="nx">app</span><span class="p">.</span><span class="nx">set</span> <span class="s1">&#39;view options&#39;</span><span class="p">,</span> <span class="p">{</span><span class="nv">layout: </span><span class="kc">true</span><span class="p">}</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <h1>Route Middleware</h1>
+
+<p>To keep things DRY and to increase readability we can apply this logic within a middleware. Multiple route middleware can be applied, and will be executed sequentially to apply further logic such as restricting access to a user account. Keeping in mind that middleware are simply functions, we can define function that returns the middleware in order to create a more expressive and flexible solution</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s1">&#39;/&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
+
+ <span class="nx">res</span><span class="p">.</span><span class="nx">render</span> <span class="s1">&#39;root.jade&#39;</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">listen</span> <span class="mi">4000</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
40 docs/010_0_express.html
@@ -9,9 +9,31 @@
<li><a href="https://github.com/visionmedia/jade">Jade</a> </li>
</ul>
-<hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p><code>view options, {layout: true}</code> is default
+<hr /> </td> <td class="code"> <div class="highlight"><pre><span class="nv">express = </span><span class="nx">require</span> <span class="s1">&#39;express&#39;</span>
+<span class="nv">app = </span><span class="nx">express</span><span class="p">.</span><span class="nx">createServer</span><span class="p">()</span>
+
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">configure</span> <span class="o">-&gt;</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">logger</span><span class="p">()</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">static</span><span class="p">(</span><span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/static&#39;</span><span class="p">)</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">configure</span> <span class="s1">&#39;development&#39;</span><span class="p">,</span> <span class="o">-&gt;</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">errorHandler</span>
+ <span class="nv">dumpExceptions: </span><span class="kc">true</span><span class="p">,</span>
+ <span class="nv">showStack: </span><span class="kc">true</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">configure</span> <span class="s1">&#39;production&#39;</span><span class="p">,</span> <span class="o">-&gt;</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">errorHandler</span>
+
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">set</span> <span class="s1">&#39;views&#39;</span><span class="p">,</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/views_010&#39;</span>
+<span class="nx">app</span><span class="p">.</span><span class="nx">set</span> <span class="s1">&#39;view engine&#39;</span><span class="p">,</span> <span class="s1">&#39;jade&#39;</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p><code>view options, {layout: true}</code> is default
so, we don't need to write this line
-app.set 'view options', {layout: true}</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>I was really confused..
+app.set 'view options', {layout: true}</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s1">&#39;/&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">render</span> <span class="s1">&#39;root&#39;</span>
+
+<span class="nv">products = </span><span class="nx">require</span> <span class="s1">&#39;./010_1_products&#39;</span>
+ </pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>I was really confused..
Everything was fine, but the partial in the /views/products/index.jade was not rendered. </p>
<ul>
@@ -28,5 +50,15 @@
<p>There is no partial directory!!!
just post directory. I renamed partial directory to product. And It works now.
-And I changed the /views/partials/product.jade ====> /views/product/index.jade </p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Still confused?
-have a look at this <a href="https://github.com/visionmedia/express/blob/master/examples/partials/views/ninja/index.jade">express github repo example</a></p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+And I changed the /views/partials/product.jade ====> /views/product/index.jade </p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>Still confused?
+have a look at this <a href="https://github.com/visionmedia/express/blob/master/examples/partials/views/ninja/index.jade">express github repo example</a></p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s1">&#39;/products&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">render</span> <span class="s1">&#39;products/index&#39;</span><span class="p">,</span> <span class="nv">locals: </span><span class="p">{</span><span class="nv">products: </span><span class="nx">products</span><span class="p">.</span><span class="nx">all</span><span class="p">}</span>
+
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s1">&#39;/products/:id&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nv">product = </span><span class="nx">products</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="nx">req</span><span class="p">.</span><span class="nx">params</span><span class="p">.</span><span class="nx">id</span><span class="p">)</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">render</span> <span class="s1">&#39;products/show&#39;</span><span class="p">,</span> <span class="nv">locals: </span><span class="p">{</span><span class="nv">product: </span><span class="nx">product</span><span class="p">}</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">listen</span> <span class="mi">4000</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
21 docs/010_1_products.html
@@ -9,4 +9,23 @@
<li><a href="https://github.com/visionmedia/jade">Jade</a> </li>
</ul>
-<hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+<hr /> </td> <td class="code"> <div class="highlight"><pre><span class="nv">products = </span><span class="p">[</span>
+ <span class="nv">id: </span><span class="mi">1</span>
+ <span class="nv">name: </span><span class="s1">&#39;Mac Book Pro&#39;</span>
+ <span class="nv">description: </span><span class="s1">&#39;Apple 13 inch Mac Book Pro Notebook&#39;</span>
+ <span class="nv">price: </span><span class="mi">1000</span>
+<span class="p">,</span>
+ <span class="nv">id: </span><span class="mi">2</span>
+ <span class="nv">name: </span><span class="s1">&#39;iPad&#39;</span>
+ <span class="nv">description: </span><span class="s1">&#39;Apple 64GB 3G iPad&#39;</span>
+ <span class="nv">price: </span><span class="mi">899</span>
+<span class="p">]</span>
+
+<span class="nv">module.exports.all = </span><span class="nx">products</span>
+
+<span class="nv">module.exports.find = </span><span class="nf">(id) -&gt;</span>
+ <span class="nv">id = </span><span class="nb">parseInt</span><span class="p">(</span><span class="nx">id</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
+ <span class="k">for</span> <span class="nx">product</span> <span class="k">in</span> <span class="nx">products</span>
+ <span class="k">if</span> <span class="nx">product</span><span class="p">.</span><span class="nx">id</span> <span class="o">is</span> <span class="nx">id</span> <span class="k">then</span> <span class="k">return</span> <span class="nx">product</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
56 docs/011_0_express.html
@@ -9,6 +9,58 @@
<li><a href="https://github.com/visionmedia/jade">Jade</a> </li>
</ul>
-<hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Middleware ordering is important.</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>By default Express does not know what to do with POST/PUT request body, so we should add the bodyParser middleware, which will parse application/x-www-form-urlencoded and application/json request bodies and place the variables in req.body</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>When using methods such as PUT with a form, we can utilize a hidden input named _method, which can be used to alter the HTTP method. To do so we first need the methodOverride middleware, which should be placed below bodyParser so that it can utilize it’s req.body containing the form values.</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>The order of app.get 'xxx' is important.
+<hr /> </td> <td class="code"> <div class="highlight"><pre><span class="nv">express = </span><span class="nx">require</span> <span class="s1">&#39;express&#39;</span>
+<span class="nv">app = </span><span class="nx">express</span><span class="p">.</span><span class="nx">createServer</span><span class="p">()</span>
+ </pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>Middleware ordering is important.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">app</span><span class="p">.</span><span class="nx">configure</span> <span class="o">-&gt;</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">logger</span><span class="p">()</span> </pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>By default Express does not know what to do with POST/PUT request body, so we should add the bodyParser middleware, which will parse application/x-www-form-urlencoded and application/json request bodies and place the variables in req.body</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">bodyParser</span><span class="p">()</span> </pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>When using methods such as PUT with a form, we can utilize a hidden input named _method, which can be used to alter the HTTP method. To do so we first need the methodOverride middleware, which should be placed below bodyParser so that it can utilize it’s req.body containing the form values.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">methodOverride</span><span class="p">()</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">static</span><span class="p">(</span><span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/static&#39;</span><span class="p">)</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">configure</span> <span class="s1">&#39;development&#39;</span><span class="p">,</span> <span class="o">-&gt;</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">errorHandler</span>
+ <span class="nv">dumpExceptions: </span><span class="kc">true</span><span class="p">,</span>
+ <span class="nv">showStack: </span><span class="kc">true</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">configure</span> <span class="s1">&#39;production&#39;</span><span class="p">,</span> <span class="o">-&gt;</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">errorHandler</span>
+
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">set</span> <span class="s1">&#39;views&#39;</span><span class="p">,</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/views_011&#39;</span>
+<span class="nx">app</span><span class="p">.</span><span class="nx">set</span> <span class="s1">&#39;view engine&#39;</span><span class="p">,</span> <span class="s1">&#39;jade&#39;</span>
+
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s1">&#39;/&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">render</span> <span class="s1">&#39;root&#39;</span>
+
+<span class="nv">products = </span><span class="nx">require</span> <span class="s1">&#39;./011_1_products&#39;</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s1">&#39;/products&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">render</span> <span class="s1">&#39;products/index&#39;</span><span class="p">,</span> <span class="nv">locals: </span><span class="p">{</span><span class="nv">products: </span><span class="nx">products</span><span class="p">.</span><span class="nx">all</span><span class="p">}</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>The order of app.get 'xxx' is important.
If you put this /products/new below the /product/:id,
-then new would be passed as a param "new".</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+then new would be passed as a param "new".</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s1">&#39;/products/new&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">render</span> <span class="s1">&#39;products/new&#39;</span><span class="p">,</span> <span class="nv">locals:</span>
+ <span class="nv">product:</span>
+ <span class="nx">req</span><span class="p">.</span><span class="nx">body</span> <span class="o">&amp;&amp;</span> <span class="nx">req</span><span class="p">.</span><span class="nx">body</span><span class="p">.</span><span class="nx">product</span> <span class="o">||</span> <span class="nx">products</span><span class="p">.</span><span class="k">new</span><span class="p">()</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s1">&#39;/products/:id&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nv">product = </span><span class="nx">products</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="nx">req</span><span class="p">.</span><span class="nx">params</span><span class="p">.</span><span class="nx">id</span><span class="p">)</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">render</span> <span class="s1">&#39;products/show&#39;</span><span class="p">,</span> <span class="nv">locals: </span><span class="p">{</span><span class="nv">product: </span><span class="nx">product</span><span class="p">}</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s1">&#39;/products/:id/edit&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nv">product = </span><span class="nx">products</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="nx">req</span><span class="p">.</span><span class="nx">params</span><span class="p">.</span><span class="nx">id</span><span class="p">)</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">render</span> <span class="s1">&#39;products/edit&#39;</span><span class="p">,</span> <span class="nv">locals: </span><span class="p">{</span><span class="nv">product: </span><span class="nx">product</span><span class="p">}</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">post</span> <span class="s1">&#39;/products/:id&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nv">id = </span><span class="nx">req</span><span class="p">.</span><span class="nx">params</span><span class="p">.</span><span class="nx">id</span>
+ <span class="nx">products</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="nx">id</span><span class="p">,</span> <span class="nx">req</span><span class="p">.</span><span class="nx">body</span><span class="p">.</span><span class="nx">product</span><span class="p">)</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">redirect</span> <span class="s1">&#39;/products/&#39;</span><span class="o">+</span><span class="nx">id</span>
+
+
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">post</span> <span class="s1">&#39;/products&#39;</span><span class="p">,</span> <span class="nf">(req,res) -&gt;</span>
+ <span class="nv">id = </span><span class="nx">products</span><span class="p">.</span><span class="nx">insert</span><span class="p">(</span><span class="nx">req</span><span class="p">.</span><span class="nx">body</span><span class="p">.</span><span class="nx">product</span><span class="p">)</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">redirect</span> <span class="s1">&#39;/products/&#39;</span><span class="o">+</span><span class="nx">id</span>
+
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">listen</span> <span class="mi">4000</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
37 docs/011_1_products.html
@@ -9,4 +9,39 @@
<li><a href="https://github.com/visionmedia/jade">Jade</a> </li>
</ul>
-<hr /> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+<hr /> </td> <td class="code"> <div class="highlight"><pre><span class="nv">products = </span><span class="p">[</span>
+ <span class="nv">id: </span><span class="mi">1</span>
+ <span class="nv">name: </span><span class="s1">&#39;Mac Book Pro&#39;</span>
+ <span class="nv">description: </span><span class="s1">&#39;Apple 13 inch Mac Book Pro Notebook&#39;</span>
+ <span class="nv">price: </span><span class="mi">1000</span>
+<span class="p">,</span>
+ <span class="nv">id: </span><span class="mi">2</span>
+ <span class="nv">name: </span><span class="s1">&#39;iPad&#39;</span>
+ <span class="nv">description: </span><span class="s1">&#39;Apple 64GB 3G iPad&#39;</span>
+ <span class="nv">price: </span><span class="mi">899</span>
+<span class="p">]</span>
+
+<span class="nv">module.exports.all = </span><span class="nx">products</span>
+
+<span class="nv">module.exports.find = </span><span class="nf">(id) -&gt;</span>
+ <span class="nv">id = </span><span class="nb">parseInt</span><span class="p">(</span><span class="nx">id</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
+ <span class="k">for</span> <span class="nx">product</span> <span class="k">in</span> <span class="nx">products</span>
+ <span class="k">if</span> <span class="nx">product</span><span class="p">.</span><span class="nx">id</span> <span class="o">is</span> <span class="nx">id</span> <span class="k">then</span> <span class="k">return</span> <span class="nx">product</span>
+
+<span class="nv">module.exports.set = </span><span class="nf">(id, product) -&gt;</span>
+ <span class="nv">id = </span><span class="nb">parseInt</span><span class="p">(</span><span class="nx">id</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
+ <span class="nv">product.id = </span><span class="nx">id</span>
+ <span class="nx">products</span><span class="p">[</span><span class="nx">id</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="nx">product</span>
+
+<span class="nv">module.exports.new = </span><span class="o">-&gt;</span>
+ <span class="nv">name : </span><span class="s1">&#39;&#39;</span>
+ <span class="nv">description: </span><span class="s1">&#39;&#39;</span>
+ <span class="nv">price: </span><span class="mi">0</span>
+
+<span class="nv">module.exports.insert = </span><span class="nf">(product) -&gt;</span>
+ <span class="nv">id = </span><span class="nx">products</span><span class="p">.</span><span class="nx">length</span> <span class="o">+</span> <span class="mi">1</span>
+ <span class="nv">product.id = </span><span class="nx">id</span>
+ <span class="nx">products</span><span class="p">[</span><span class="nx">id</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="nx">product</span>
+ <span class="nx">id</span>
+
+</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
View
89 docs/012_0_file_upload.html
@@ -14,12 +14,93 @@
</ul> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>connect-form uses Formidable.
https://github.com/felixge/node-formidable</p>
-<hr /> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>connect-form middleware uses the formidable middleware to parse urlencoded and multipart form data </p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>If you want the files written to incomingForm.uploadDir to include the extensions of the original files, set this property to true. </p>
+<hr /> </td> <td class="code"> <div class="highlight"><pre><span class="nv">express = </span><span class="nx">require</span> <span class="s1">&#39;express&#39;</span>
+<span class="nv">form = </span><span class="nx">require</span> <span class="s1">&#39;connect-form&#39;</span>
+<span class="nv">util = </span><span class="nx">require</span> <span class="s1">&#39;util&#39;</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>connect-form middleware uses the formidable middleware to parse urlencoded and multipart form data </p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p>If you want the files written to incomingForm.uploadDir to include the extensions of the original files, set this property to true. </p>
<p><code>maxFieldsSize = 2 * 1024 * 1024</code></p>
-<p>Limits the amount of memory a field (not file) can allocate in bytes. I this value is exceeded, an 'error' event is emitted. The default size is 2MB.</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>We have to use binary instead of utf-8.</p>
+<p>Limits the amount of memory a field (not file) can allocate in bytes. I this value is exceeded, an 'error' event is emitted. The default size is 2MB.</p> </td> <td class="code"> <div class="highlight"><pre></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">&#182;</a> </div> <p>We have to use binary instead of utf-8.</p>
-<p>https://github.com/felixge/node-formidable </p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Photos</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>connect-form adds the req.form object
+<p>https://github.com/felixge/node-formidable </p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">app = </span><span class="nx">express</span><span class="p">.</span><span class="nx">createServer</span> <span class="nx">form</span>
+ <span class="nv">keepExtensions: </span><span class="kc">true</span>
+ <span class="nv">encoding: </span><span class="s1">&#39;binary&#39;</span>
+ <span class="nv">uploadDir: </span><span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/static/uploads/photos&#39;</span>
+ <span class="nv">maxFieldsSize: </span><span class="mi">2</span> <span class="o">*</span> <span class="mi">1024</span> <span class="o">*</span> <span class="mi">1024</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">configure</span> <span class="o">-&gt;</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">logger</span><span class="p">()</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">bodyParser</span><span class="p">()</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">methodOverride</span><span class="p">()</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">static</span><span class="p">(</span><span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/static&#39;</span><span class="p">)</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">configure</span> <span class="s1">&#39;development&#39;</span><span class="p">,</span> <span class="o">-&gt;</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">errorHandler</span>
+ <span class="nv">dumpExceptions: </span><span class="kc">true</span><span class="p">,</span>
+ <span class="nv">showStack: </span><span class="kc">true</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">configure</span> <span class="s1">&#39;production&#39;</span><span class="p">,</span> <span class="o">-&gt;</span>
+ <span class="nx">app</span><span class="p">.</span><span class="nx">use</span> <span class="nx">express</span><span class="p">.</span><span class="nx">errorHandler</span>
+
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">set</span> <span class="s1">&#39;views&#39;</span><span class="p">,</span> <span class="nx">__dirname</span> <span class="o">+</span> <span class="s1">&#39;/views_012&#39;</span>
+<span class="nx">app</span><span class="p">.</span><span class="nx">set</span> <span class="s1">&#39;view engine&#39;</span><span class="p">,</span> <span class="s1">&#39;jade&#39;</span>
+
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s1">&#39;/&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">render</span> <span class="s1">&#39;root&#39;</span> </pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">&#182;</a> </div> <p>Photos</p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">photos = </span><span class="nx">require</span> <span class="s1">&#39;./012_1_photos&#39;</span>
+<span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s1">&#39;/photos/new&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">render</span> <span class="s1">&#39;photos/new&#39;</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s1">&#39;/photos&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nx">photos</span><span class="p">.</span><span class="nx">list</span> <span class="nf">(err, photo_list) -&gt;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">render</span> <span class="s1">&#39;photos/index&#39;</span><span class="p">,</span> <span class="nv">locals: </span><span class="p">{</span><span class="nv">photos: </span><span class="nx">photo_list</span><span class="p">}</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">post</span> <span class="s1">&#39;/photos&#39;</span><span class="p">,</span> <span class="nf">(req, res, next) -&gt;</span> </pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">&#182;</a> </div> <p>connect-form adds the req.form object
we can (optionally) define onComplete, passing
-the exception (if any) fields parsed, and files parsed</p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Products </p> </td> <td class="code"> <div class="highlight"><pre>undefined</pre></div> </td> </tr> </tbody> </table> </div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="000_intro.html"> 000_intro.coffee </a> <a class="source" href="001_http.html"> 001_http.coffee </a> <a class="source" href="002_child_process.html"> 002_child_process.coffee </a> <a class="source" href="003_pump.html"> 003_pump.coffee </a> <a class="source" href="004_step.html"> 004_step.coffee </a> <a class="source" href="005_chat.html"> 005_chat.coffee </a> <a class="source" href="006_socket_chat.html"> 006_socket_chat.coffee </a> <a class="source" href="007_socket.io_chat.html"> 007_socket.io_chat.coffee </a> <a class="source" href="008_0_connect.html"> 008_0_connect.coffee </a> <a class="source" href="008_1_serve-js.html"> 008_1_serve-js.coffee </a> <a class="source" href="008_2_log-it.html"> 008_2_log-it.coffee </a> <a class="source" href="009_express.html"> 009_express.coffee </a> <a class="source" href="010_0_express.html"> 010_0_express.coffee </a> <a class="source" href="010_1_products.html"> 010_1_products.coffee </a> <a class="source" href="011_0_express.html"> 011_0_express.coffee </a> <a class="source" href="011_1_products.html"> 011_1_products.coffee </a> <a class="source" href="012_0_file_upload.html"> 012_0_file_upload.coffee </a> <a class="source" href="012_1_photos.html"> 012_1_photos.coffee </a> <a class="source" href="012_2_products.html"> 012_2_products.coffee </a> <a class="source" href="013_0_auth.html"> 013_0_auth.coffee </a> <a class="source" href="013_1_photos.html"> 013_1_photos.coffee </a> <a class="source" href="013_2_products.html"> 013_2_products.coffee </a> <a class="source" href="013_3_users.html"> 013_3_users.coffee </a> <a class="source" href="014_0_tools.html"> 014_0_tools.coffee </a> <a class="source" href="015_deploy.html"> 015_deploy.coffee </a> <a class="source" href="016_coffeescript.html"> 016_coffeescript.coffee </a> <a class="source" href="017_0_modules.html"> 017_0_modules.coffee </a> <a class="source" href="017_1_test_modules.html"> 017_1_test_modules.coffee </a> <a class="source" href="018_0_mongoose.html"> 018_0_mongoose.coffee </a> <a class="source" href="018_1_photos.html"> 018_1_photos.coffee </a> <a class="source" href="018_2_products.html"> 018_2_products.coffee </a> <a class="source" href="018_3_users.html"> 018_3_users.coffee </a> <a class="source" href="019_async_interation.html"> 019_async_interation.coffee </a> <a class="source" href="020_tdd.html"> 020_tdd.coffee </a> <a class="source" href="021_mongoose_update.html"> 021_mongoose_update.coffee </a> <a class="source" href="022_bundling.html"> 022_bundling.coffee </a> <a class="source" href="023_express_resources.html"> 023_express_resources.coffee </a> <a class="source" href="024_0_benchmark.html"> 024_0_benchmark.coffee </a> <a class="source" href="024_1_test.html"> 024_1_test.coffee </a> <a class="source" href="024_2_statistics.html"> 024_2_statistics.coffee </a> <a class="source" href="025_nginx.html"> 025_nginx.coffee </a> <a class="source" href="026_0_everyauth.html"> 026_0_everyauth.coffee </a> <a class="source" href="026_1_users.html"> 026_1_users.coffee </a> <a class="source" href="027_0_kue.html"> 027_0_kue.coffee </a> <a class="source" href="027_1_kue_consumer.html"> 027_1_kue_consumer.coffee </a> <a class="source" href="028_classes_prototype_closure.html"> 028_classes_prototype_closure.coffee </a> </div> </div> </div> </body> </html>
+the exception (if any) fields parsed, and files parsed</p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">req</span><span class="p">.</span><span class="nx">form</span><span class="p">.</span><span class="nx">complete</span> <span class="nf">(err, fields, files) -&gt;</span>
+ <span class="k">if</span> <span class="nx">err</span>
+ <span class="nx">next</span> <span class="nx">err</span>
+ <span class="k">else</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s2">&quot;\nuploaded #{files.image.filename} to #{files.image.path}&quot;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">redirect</span> <span class="s2">&quot;/photos&quot;</span>
+
+ <span class="nx">req</span><span class="p">.</span><span class="nx">form</span><span class="p">.</span><span class="kc">on</span> <span class="s2">&quot;progress&quot;</span><span class="p">,</span> <span class="nf">(bytesReceived, bytesExpected) -&gt;</span>
+ <span class="nv">percent = </span><span class="p">(</span><span class="nx">bytesReceived</span> <span class="err">/ bytesExpected * 100) | 0</span>
+ <span class="nx">process</span><span class="p">.</span><span class="nx">stdout</span><span class="p">.</span><span class="nx">write</span> <span class="s2">&quot;Uploading: #{percent}% \r&quot;</span></pre></div> </td> </tr> <tr id="section-8"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-8">&#182;</a> </div> <p>Products </p> </td> <td class="code"> <div class="highlight"><pre><span class="nv">products = </span><span class="nx">require</span> <span class="s1">&#39;./012_2_products&#39;</span>
+<span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s1">&#39;/products&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nx">res</span><span class="p">.</span><span class="nx">render</span> <span class="s1">&#39;products/index&#39;</span><span class="p">,</span> <span class="nv">locals: </span><span class="p">{</span><span class="nv">products: </span><span class="nx">products</span><span class="p">.</span><span class="nx">all</span><span class="p">}</span>
+
+<span class="nx">app</span><span class="p">.</span><span class="nx">get</span> <span class="s1">&#39;/products/new&#39;</span><span class="p">,</span> <span class="nf">(req, res) -&gt;</span>
+ <span class="nx">photos</span><span class="p">.</span><span class="nx">list</span> <span class="nf">(err, photo_list) -&gt;</span>
+ <span