Skip to content
Myr

Added app.register() docs

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 9a8166d · Browse files · 8 files+438 added−131 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+438 added−131 removed

  • other:+438 added−131 removed

8 files+438 added−131 removed

modified:docs/api.html+169 added-76 removed
108 unmodified lines
109 </head>110 <body>111<table id="source"><tbody><tr><td><h1>Express</h1><p>High performance web framework for <a href="http://nodejs.org">node</a>.</p></td><td></td></tr><tr class="filename"><td><h2 id="lib/express/index.js"><a href="#">index</a></h2></td><td>lib/express/index.js</td></tr><tr class="code">112<td class="docs">113<p>Re-export connect auto-loaders.</p>114115<p>This prevents the need to <code>require('connect')</code> in order116to access core middleware, so for example <code>express.logger()</code> instead117of <code>require('connect').logger()</code>.118 </p>119</td>120<td class="code">121<pre><code><span class="keyword">var</span> <span class="variable">exports</span> = <span class="variable">module</span>.<span class="variable">exports</span> = <span class="variable">require</span>(<span class="string">'connect'</span>).<span class="variable">middleware</span>;</code></pre>122</td>123</tr>124<tr class="code">125<td class="docs">126<p>Framework version.127 </p>128</td>129<td class="code">
307 unmodified lines
437</td>438</tr>439<tr class="code">440<td class="docs">428<p>Transfer the given <code>file</code>. Automatically sets the <em>Content-Type</em>429response header, and responds with 404 / 500 appropriately.</p>441<p>Transfer the file at the given <code>path</code>. Automatically sets 442the <em>Content-Type</em> response header via <code>res.contentType()</code>. </p>443444<p>The given callback <code>fn</code> is invoked when an error occurs,445passing it as the first argument, or when the file is transferred,446passing the path as the second argument.</p>447448<h2></h2>449433<ul><li><p><strong>param</strong>: <em>String</em> file</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>450<ul><li><p><strong>param</strong>: <em>String</em> path</p></li><li><p><strong>param</strong>: <em>Function</em> fn</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>451</td>452<td class="code">436<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">sendfile</span> = <span class="keyword">function</span>(<span class="variable">file</span>){453<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">sendfile</span> = <span class="keyword">function</span>(<span class="variable">path</span>, <span class="variable">fn</span>){454 <span class="keyword">var</span> <span class="variable">self</span> = <span class="this">this</span>;438 <span class="variable">fs</span>.<span class="variable">readFile</span>(<span class="variable">file</span>, <span class="keyword">function</span>(<span class="variable">err</span>, <span class="variable">buf</span>){455 <span class="variable">fs</span>.<span class="variable">readFile</span>(<span class="variable">path</span>, <span class="keyword">function</span>(<span class="variable">err</span>, <span class="variable">buf</span>){456 <span class="keyword">if</span> (<span class="variable">err</span>) {440 <span class="variable">self</span>.<span class="variable">send</span>(<span class="variable">err</span>.<span class="variable">errno</span> === <span class="variable">process</span>.<span class="class">ENOENT</span>441 ? <span class="number integer">404</span>442 : <span class="number integer">500</span>);457 <span class="keyword">if</span> (<span class="variable">fn</span>) {458 <span class="variable">fn</span>(<span class="variable">err</span>, <span class="variable">path</span>);459 } <span class="keyword">else</span> {460 <span class="variable">self</span>.<span class="variable">req</span>.<span class="variable">next</span>(<span class="variable">err</span>);461 }462 } <span class="keyword">else</span> {444 <span class="variable">self</span>.<span class="variable">contentType</span>(<span class="variable">file</span>);463 <span class="variable">self</span>.<span class="variable">contentType</span>(<span class="variable">path</span>);464 <span class="variable">self</span>.<span class="variable">send</span>(<span class="variable">buf</span>);465 <span class="variable">fn</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">fn</span>(<span class="keyword">null</span>, <span class="variable">path</span>);466 }467 });468};</code></pre>469</td>
36 unmodified lines
506</td>507</tr>508<tr class="code">509<td class="docs">490<p>Transfer the given <code>file</code> with optional <code>filename</code> as an attachment.</p>510<p>Transfer the file at the given <code>path</code>, with optional 511<code>filename</code> as an attachment. Once transferred, or if an512error occurs <code>fn</code> is called with the error and path.</p>513514<h2></h2>515494<ul><li><p><strong>param</strong>: <em>String</em> file</p></li><li><p><strong>param</strong>: <em>String</em> filename</p></li><li><p><strong>return</strong>: <em>Type</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>516<ul><li><p><strong>param</strong>: <em>String</em> path</p></li><li><p><strong>param</strong>: <em>String</em> filename</p></li><li><p><strong>param</strong>: <em>Function</em> fn</p></li><li><p><strong>return</strong>: <em>Type</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>517</td>518<td class="code">497<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">download</span> = <span class="keyword">function</span>(<span class="variable">file</span>, <span class="variable">filename</span>){498 <span class="this">this</span>.<span class="variable">attachment</span>(<span class="variable">filename</span> || <span class="variable">file</span>).<span class="variable">sendfile</span>(<span class="variable">file</span>);519<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">download</span> = <span class="keyword">function</span>(<span class="variable">path</span>, <span class="variable">filename</span>, <span class="variable">fn</span>){520 <span class="this">this</span>.<span class="variable">attachment</span>(<span class="variable">filename</span> || <span class="variable">path</span>).<span class="variable">sendfile</span>(<span class="variable">path</span>, <span class="variable">fn</span>);521};</code></pre>522</td>523</tr>524<tr class="code">
67 unmodified lines
592 <span class="variable">map</span>.<span class="variable">__proto__</span> = <span class="this">this</span>.<span class="variable">app</span>.<span class="variable">redirects</span>;593594 <span class="comment">// Attempt mapped redirect</span>595 <span class="keyword">var</span> <span class="variable">mapped</span> = <span class="keyword">typeof</span> <span class="variable">map</span>[<span class="variable">url</span>] === <span class="string">'function'</span>574 ? <span class="variable">map</span>[<span class="variable">url</span>](<span class="this">this</span>.<span class="variable">req</span>, <span class="this">this</span>, <span class="this">this</span>.<span class="variable">req</span>.<span class="variable">params</span>.<span class="variable">path</span>)596 ? <span class="variable">map</span>[<span class="variable">url</span>](<span class="this">this</span>.<span class="variable">req</span>, <span class="this">this</span>)597 : <span class="variable">map</span>[<span class="variable">url</span>];598599 <span class="comment">// Perform redirect</span>600 <span class="this">this</span>.<span class="variable">writeHead</span>(<span class="variable">status</span> || <span class="number integer">302</span>, { <span class="string">'Location'</span>: <span class="variable">mapped</span> || <span class="variable">url</span> });601 <span class="this">this</span>.<span class="variable">end</span>();602};603</code></pre>604</td>605</tr><tr class="filename"><td><h2 id="lib/express/utils.js"><a href="#">utils</a></h2></td><td>lib/express/utils.js</td></tr><tr class="code">606<td class="docs">607<p>Parse mini markdown implementation.608The following conversions are supported,609primarily for the "flash" middleware:</p>610611<p> <em>foo</em> or <em>foo</em> become &lt;em&gt;foo&lt;/em&gt;612 <strong>foo</strong> or <strong>foo</strong> become &lt;strong&gt;foo&lt;/strong&gt;613 <a href="B">A</a> becomes &lt;a href="B"&gt;A&lt;/a&gt;</p>614615<h2></h2>616617<ul><li><p><strong>param</strong>: <em>String</em> str</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>618</td>619<td class="code">620<pre><code><span class="variable">exports</span>.<span class="variable">miniMarkdown</span> = <span class="keyword">function</span>(<span class="variable">str</span>){621 <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">str</span>)622 .<span class="variable">replace</span>(<span class="regexp">/(__|\*\*)(.*?)\1/g</span>, <span class="string">'&lt;strong&gt;$2&lt;/strong&gt;'</span>)623 .<span class="variable">replace</span>(<span class="regexp">/(_|\*)(.*?)\1/g</span>, <span class="string">'&lt;em&gt;$2&lt;/em&gt;'</span>)624 .<span class="variable">replace</span>(<span class="regexp">/\[([^\]]+)\]\(([^)]+)\)/g</span>, <span class="string">'&lt;a href=&quot;$2&quot;&gt;$1&lt;/a&gt;'</span>);625};</code></pre>626</td>627</tr>628<tr class="code">629<td class="docs">630<p>Escape special characters in the given string of html.</p>631632<h2></h2>633634<ul><li><p><strong>param</strong>: <em>String</em> html</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>635</td>636<td class="code">637<pre><code><span class="variable">exports</span>.<span class="variable">htmlEscape</span> = <span class="keyword">function</span>(<span class="variable">html</span>) {638 <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">html</span>)639 .<span class="variable">replace</span>(<span class="regexp">/&amp;/g</span>, <span class="string">'&amp;'</span>)640 .<span class="variable">replace</span>(<span class="regexp">/&quot;/g</span>, <span class="string">'&quot;'</span>)641 .<span class="variable">replace</span>(<span class="regexp">/&lt;/g</span>, <span class="string">'&lt;'</span>)642 .<span class="variable">replace</span>(<span class="regexp">/&gt;/g</span>, <span class="string">'&gt;'</span>);643};</code></pre>644</td>645</tr><tr class="filename"><td><h2 id="lib/express/server.js"><a href="#">server</a></h2></td><td>lib/express/server.js</td></tr><tr class="code">646<td class="docs">647<p>Module dependencies.648 </p>
23 unmodified lines
672 <span class="this">this</span>.<span class="variable">settings</span> = {};673 <span class="this">this</span>.<span class="variable">redirects</span> = {};674 <span class="this">this</span>.<span class="variable">viewHelpers</span> = {};675 <span class="this">this</span>.<span class="variable">dynamicViewHelpers</span> = {};676 <span class="this">this</span>.<span class="variable">errorHandlers</span> = [];677 <span class="variable">connect</span>.<span class="class">Server</span>.<span class="variable">call</span>(<span class="this">this</span>, <span class="variable">middleware</span> || []);678679 <span class="comment">// Default &quot;home&quot; to / </span>680 <span class="this">this</span>.<span class="variable">set</span>(<span class="string">'home'</span>, <span class="string">'/'</span>);
38 unmodified lines
719</td>720</tr>721<tr class="code">722<td class="docs">723<p>Stack error handler callbacks, then listen on the given724<code>port</code> and <code>host</code>.</p>725726<h2></h2>727728<ul><li><p><strong>param</strong>: <em>Number | String</em> port</p></li><li><p><strong>param</strong>: <em>String</em> host</p></li><li><p><strong>return</strong>: <em>Type</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>729</td>730<td class="code">731<pre><code><span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">listen</span> = <span class="keyword">function</span>(){732 <span class="this">this</span>.<span class="variable">errorHandlers</span>.<span class="variable">forEach</span>(<span class="keyword">function</span>(<span class="variable">fn</span>){733 <span class="this">this</span>.<span class="variable">use</span>(<span class="keyword">function</span>(<span class="variable">err</span>, <span class="variable">req</span>, <span class="variable">res</span>, <span class="variable">next</span>){734 <span class="variable">fn</span>.<span class="variable">apply</span>(<span class="this">this</span>, <span class="variable">arguments</span>);735 });736 }, <span class="this">this</span>);737 <span class="variable">connect</span>.<span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">listen</span>.<span class="variable">apply</span>(<span class="this">this</span>, <span class="variable">arguments</span>);738};</code></pre>739</td>740</tr>741<tr class="code">742<td class="docs">743<p>Proxy <code>connect.Server#use()</code> to apply settings to744mounted applications.</p>745746<h2></h2>
52 unmodified lines
799</td>800</tr>801<tr class="code">802<td class="docs">803<h2>See view.register.</h2>804805<h2></h2>806807<ul><li><p><strong>return</strong>: <em>Server</em> for chaining</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>808</td>809<td class="code">810<pre><code><span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">register</span> = <span class="keyword">function</span>(){811 <span class="variable">view</span>.<span class="variable">register</span>.<span class="variable">apply</span>(<span class="this">this</span>, <span class="variable">arguments</span>);812 <span class="keyword">return</span> <span class="this">this</span>;813};</code></pre>814</td>815</tr>816<tr class="code">817<td class="docs">818<p>Register the given view helpers <code>obj</code>. This method819can be called several times to apply additional helpers.</p>820821<h2></h2>
24 unmodified lines
846</td>847</tr>848<tr class="code">849<td class="docs">752<p>Assign a custom exception handler callback <code>fn</code>.</p>850<p>Assign a custom exception handler callback <code>fn</code>.851These handlers are always <em>last</em> in the middleware stack.</p>852853<h2></h2>854855<ul><li><p><strong>param</strong>: <em>Function</em> fn</p></li><li><p><strong>return</strong>: <em>Server</em> for chaining</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>856</td>857<td class="code">858<pre><code><span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">error</span> = <span class="keyword">function</span>(<span class="variable">fn</span>){760 <span class="this">this</span>.<span class="variable">use</span>(<span class="keyword">function</span>(<span class="variable">err</span>, <span class="variable">req</span>, <span class="variable">res</span>, <span class="variable">next</span>){761 <span class="variable">fn</span>.<span class="variable">apply</span>(<span class="this">this</span>, <span class="variable">arguments</span>);762 });859 <span class="this">this</span>.<span class="variable">errorHandlers</span>.<span class="variable">push</span>(<span class="variable">fn</span>);860 <span class="keyword">return</span> <span class="this">this</span>;861};</code></pre>862</td>863</tr>
91 unmodified lines
955 <span class="keyword">return</span> <span class="variable">arguments</span>.<span class="variable">callee</span>;956})(<span class="string">'get'</span>)(<span class="string">'post'</span>)(<span class="string">'put'</span>)(<span class="string">'del'</span>);957</code></pre>958</td>862</tr><tr class="filename"><td><h2 id="lib/express/utils.js"><a href="#">utils</a></h2></td><td>lib/express/utils.js</td></tr><tr class="code">863<td class="docs">864<p>Parse mini markdown implementation.865The following conversions are supported,866primarily for the "flash" middleware:</p>867868<p> <em>foo</em> or <em>foo</em> become &lt;em&gt;foo&lt;/em&gt;869 <strong>foo</strong> or <strong>foo</strong> become &lt;strong&gt;foo&lt;/strong&gt;870 <a href="B">A</a> becomes &lt;a href="B"&gt;A&lt;/a&gt;</p>871872<h2></h2>873874<ul><li><p><strong>param</strong>: <em>String</em> str</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>875</td>876<td class="code">877<pre><code><span class="variable">exports</span>.<span class="variable">miniMarkdown</span> = <span class="keyword">function</span>(<span class="variable">str</span>){878 <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">str</span>)879 .<span class="variable">replace</span>(<span class="regexp">/(__|\*\*)(.*?)\1/g</span>, <span class="string">'&lt;strong&gt;$2&lt;/strong&gt;'</span>)880 .<span class="variable">replace</span>(<span class="regexp">/(_|\*)(.*?)\1/g</span>, <span class="string">'&lt;em&gt;$2&lt;/em&gt;'</span>)881 .<span class="variable">replace</span>(<span class="regexp">/\[([^\]]+)\]\(([^)]+)\)/g</span>, <span class="string">'&lt;a href=&quot;$2&quot;&gt;$1&lt;/a&gt;'</span>);882};</code></pre>883</td>884</tr>885<tr class="code">886<td class="docs">887<p>Escape special characters in the given string of html.</p>888889<h2></h2>890891<ul><li><p><strong>param</strong>: <em>String</em> html</p></li><li><p><strong>return</strong>: <em>String</em> </p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>892</td>893<td class="code">894<pre><code><span class="variable">exports</span>.<span class="variable">htmlEscape</span> = <span class="keyword">function</span>(<span class="variable">html</span>) {895 <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">html</span>)896 .<span class="variable">replace</span>(<span class="regexp">/&amp;/g</span>, <span class="string">'&amp;'</span>)897 .<span class="variable">replace</span>(<span class="regexp">/&quot;/g</span>, <span class="string">'&quot;'</span>)898 .<span class="variable">replace</span>(<span class="regexp">/&lt;/g</span>, <span class="string">'&lt;'</span>)899 .<span class="variable">replace</span>(<span class="regexp">/&gt;/g</span>, <span class="string">'&gt;'</span>);900};</code></pre>901</td>959</tr><tr class="filename"><td><h2 id="lib/express/view.js"><a href="#">view</a></h2></td><td>lib/express/view.js</td></tr><tr class="code">960<td class="docs">961<p>Module dependencies.962 </p>
30 unmodified lines
993</td>994</tr>995<tr class="code">996<td class="docs">940<p>Clear the view cache.</p>997<p>Register the given template engine <code>exports</code>998as <code>ext</code>. For example we may wish to map ".html"999files to jade:</p>1000942<ul><li><p><strong>api</strong>: <em>public</em></p></li></ul>1001<p> app.register('.html', require('jade'));</p>10021003<p>This is also useful for libraries that may not1004match extensions correctly. For example my haml.js1005library is installed from npm as "hamljs" so instead1006of layout.hamljs, we can register the engine as ".haml":</p>10071008<p> app.register('.haml', require('haml-js'));</p>10091010<p>For engines that do not comply with the Express1011specification, we can also wrap their api this way.</p>10121013<p> app.register('.foo', {1014 render: function(str, options) {1015 // perhaps their api is1016 // foo.toHTML(str, options);1017 }1018 });</p>10191020<h2></h2>10211022<ul><li><p><strong>param</strong>: <em>String</em> ext</p></li><li><p><strong>param</strong>: <em>Object</em> obj</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>1023</td>1024<td class="code">945<pre><code><span class="variable">exports</span>.<span class="variable">clearCache</span> = <span class="keyword">function</span>(){946 <span class="variable">viewCache</span> = {};1025<pre><code><span class="variable">exports</span>.<span class="variable">register</span> = <span class="keyword">function</span>(<span class="variable">ext</span>, <span class="variable">exports</span>) {1026 <span class="variable">cache</span>[<span class="variable">ext</span>] = <span class="variable">exports</span>;1027};</code></pre>1028</td>1029</tr>1030<tr class="code">
71 unmodified lines
1102<ul><li><code>context|scope</code> Template evaluation context (<code>this</code>)</li><li><code>locals</code> Object containing local variables</li><li><code>debug</code> Output debugging information</li></ul>11031104<h2></h2>11051026<ul><li><p><strong>param</strong>: <em>String</em> view</p></li><li><p><strong>param</strong>: <em>Object</em> options</p></li><li><p><strong>param</strong>: <em>Function</em> fn</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>1106<ul><li><p><strong>param</strong>: <em>String</em> view</p></li><li><p><strong>param</strong>: <em>Object | Function</em> options or callback function</p></li><li><p><strong>param</strong>: <em>Function</em> fn</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>1107</td>1108<td class="code">1109<pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">render</span> = <span class="keyword">function</span>(<span class="variable">view</span>, <span class="variable">options</span>, <span class="variable">fn</span>){1030 <span class="variable">options</span> = <span class="variable">options</span> || {};1031 <span class="keyword">var</span> <span class="variable">defaultEngine</span> = <span class="this">this</span>.<span class="variable">app</span>.<span class="variable">set</span>(<span class="string">'view engine'</span>);1110 <span class="comment">// Support callback function as second arg</span>1111 <span class="keyword">if</span> (<span class="keyword">typeof</span> <span class="variable">options</span> === <span class="string">'function'</span>) {1112 <span class="variable">fn</span> = <span class="variable">options</span>, <span class="variable">options</span> = {};1113 }1114 1115 <span class="keyword">var</span> <span class="variable">options</span> = <span class="variable">options</span> || {},1116 <span class="variable">viewOptions</span> = <span class="this">this</span>.<span class="variable">app</span>.<span class="variable">set</span>(<span class="string">'view options'</span>),1117 <span class="variable">defaultEngine</span> = <span class="this">this</span>.<span class="variable">app</span>.<span class="variable">set</span>(<span class="string">'view engine'</span>);11181119 <span class="comment">// Mixin &quot;view options&quot;</span>1120 <span class="keyword">if</span> (<span class="variable">viewOptions</span>) <span class="variable">options</span>.<span class="variable">__proto__</span> = <span class="variable">viewOptions</span>;11211122 <span class="comment">// Support &quot;view engine&quot; setting</span>1123 <span class="keyword">if</span> (<span class="variable">view</span>.<span class="variable">indexOf</span>(<span class="string">'.'</span>) &<span class="variable">lt</span>; <span class="number integer">0</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">defaultEngine</span>) {1124 <span class="variable">view</span> += <span class="string">'.'</span> + <span class="variable">defaultEngine</span>;1125 }
24 unmodified lines
1150 }11511152 <span class="comment">// Partials support</span>1153 <span class="keyword">if</span> (<span class="variable">options</span>.<span class="variable">partial</span>) {1065 <span class="variable">root</span> += <span class="string">'/partials'</span>;1154 <span class="variable">root</span> = <span class="this">this</span>.<span class="variable">app</span>.<span class="variable">set</span>(<span class="string">'partials'</span>)1155 ? <span class="this">this</span>.<span class="variable">app</span>.<span class="variable">set</span>(<span class="string">'partials'</span>)1156 : <span class="variable">root</span> + <span class="string">'/partials'</span>;1157 }11581159 <span class="comment">// View path</span>1160 <span class="keyword">var</span> <span class="variable">path</span> = <span class="variable">view</span>[<span class="number integer">0</span>] === <span class="string">'/'</span>
4 unmodified lines
1165 <span class="variable">options</span>.<span class="variable">locals</span> = <span class="variable">options</span>.<span class="variable">locals</span> || {};1166 <span class="variable">options</span>.<span class="variable">locals</span>.<span class="variable">__filename</span> = <span class="variable">options</span>.<span class="variable">filename</span> = <span class="variable">path</span>;11671168 <span class="comment">// Dynamic helper support</span>1169 <span class="keyword">if</span> (<span class="variable">options</span>.<span class="variable">dynamicHelpers</span> !== <span class="variable">false</span>) {1078 <span class="keyword">var</span> <span class="variable">keys</span> = <span class="class">Object</span>.<span class="variable">keys</span>(<span class="variable">dynamicHelpers</span>);1079 <span class="keyword">for</span> (<span class="keyword">var</span> <span class="variable">i</span> = <span class="number integer">0</span>, <span class="variable">len</span> = <span class="variable">keys</span>.<span class="variable">length</span>; <span class="variable">i</span> &<span class="variable">lt</span>; <span class="variable">len</span>; ++<span class="variable">i</span>) {1080 <span class="keyword">var</span> <span class="variable">key</span> = <span class="variable">keys</span>[<span class="variable">i</span>],1081 <span class="variable">val</span> = <span class="variable">dynamicHelpers</span>[<span class="variable">key</span>];1082 <span class="keyword">if</span> (<span class="keyword">typeof</span> <span class="variable">val</span> === <span class="string">'function'</span>) {1083 <span class="variable">helpers</span>[<span class="variable">key</span>] = <span class="variable">val</span>.<span class="variable">call</span>(1084 <span class="this">this</span>.<span class="variable">app</span>, 1085 <span class="this">this</span>.<span class="variable">req</span>, 1086 <span class="this">this</span>, 1087 <span class="this">this</span>.<span class="variable">req</span>.<span class="variable">params</span>.<span class="variable">path</span>);1170 <span class="keyword">var</span> <span class="variable">keys</span> = <span class="class">Object</span>.<span class="variable">keys</span>(<span class="variable">dynamicHelpers</span>);1171 <span class="keyword">for</span> (<span class="keyword">var</span> <span class="variable">i</span> = <span class="number integer">0</span>, <span class="variable">len</span> = <span class="variable">keys</span>.<span class="variable">length</span>; <span class="variable">i</span> &<span class="variable">lt</span>; <span class="variable">len</span>; ++<span class="variable">i</span>) {1172 <span class="keyword">var</span> <span class="variable">key</span> = <span class="variable">keys</span>[<span class="variable">i</span>],1173 <span class="variable">val</span> = <span class="variable">dynamicHelpers</span>[<span class="variable">key</span>];1174 <span class="keyword">if</span> (<span class="keyword">typeof</span> <span class="variable">val</span> === <span class="string">'function'</span>) {1175 <span class="variable">helpers</span>[<span class="variable">key</span>] = <span class="variable">val</span>.<span class="variable">call</span>(1176 <span class="this">this</span>.<span class="variable">app</span>, 1177 <span class="this">this</span>.<span class="variable">req</span>, 1178 <span class="this">this</span>);1179 }1180 }1181 }11821183 <span class="comment">// Always expose partial() as a local</span>
32 unmodified lines
1216 <span class="comment">// Layout support</span>1217 <span class="keyword">if</span> (<span class="variable">layout</span>) {1218 <span class="variable">options</span>.<span class="variable">layout</span> = <span class="variable">false</span>;1219 <span class="variable">options</span>.<span class="variable">locals</span>.<span class="variable">body</span> = <span class="variable">str</span>;1220 <span class="variable">options</span>.<span class="variable">isLayout</span> = <span class="variable">true</span>;1221 <span class="variable">self</span>.<span class="variable">render</span>(<span class="variable">layout</span>, <span class="variable">options</span>, <span class="variable">fn</span>);1222 } <span class="keyword">else</span> <span class="keyword">if</span> (<span class="variable">partial</span>) {1223 <span class="keyword">return</span> <span class="variable">str</span>;1224 } <span class="keyword">else</span> <span class="keyword">if</span> (<span class="variable">fn</span>) {
9 unmodified lines
modified:docs/guide.1+137 added-14 removed
72 unmodified lines
73.74.nf7576app\.configure(function(){77 app\.use(connect\.methodOverride());78 app\.use(connect\.bodyDecoder());77 app\.use(express\.methodOverride());78 app\.use(express\.bodyDecoder());79 app\.use(app\.router);80 app\.use(connect\.staticProvider(__dirname + \'/public\'));80 app\.use(express\.staticProvider(__dirname + \'/public\'));81});8283app\.configure(\'development\', function(){84 app\.use(connect\.errorHandler({ dumpExceptions: true, showStack: true }));84 app\.use(express\.errorHandler({ dumpExceptions: true, showStack: true }));85});8687app\.configure(\'production\', function(){88 app\.use(connect\.errorHandler());88 app\.use(express\.errorHandler());89});90.91.fi92.
49 unmodified lines
142.143.IP "\(bu" 4144\fIview engine\fR Default view engine name for views rendered without extensions145.146.IP "\(bu" 4147\fIview options\fR An object specifying global view options148.149.IP "\(bu" 4150\fIpartials\fR Root view partials directory defaulting to \fIviews\fR/partials\.151.152.IP "" 0153.154.SS "Routing"155Express utilizes the HTTP verbs to provide a meaningful, expressive routing API\. For example we may want to render a user\'s account for the path \fI/user/12\fR, this can be done by defining the route below\. The values associated to the named placeholders are available as \fBreq\.params\fR\.
127 unmodified lines
283.IP "" 4284.285.nf286281var connect = require(\'connect\'),282 express = require(\'express\');287var express = require(\'express\');288289var app = express\.createServer(285 connect\.logger(),286 connect\.bodyDecoder()290 express\.logger(),291 express\.bodyDecoder()292);293.294.fi295.
5 unmodified lines
301.IP "" 4302.303.nf304300app\.use(connect\.logger({ format: \':method :uri\' }));305app\.use(express\.logger({ format: \':method :uri\' }));306.307.fi308.309.IP "" 0310.311.P312Typically with connect middleware you would \fIrequire(\'connect\')\fR like so:313.314.IP "" 4315.316.nf317318var connect = require(\'connect\');319app\.use(connect\.logger());320.321.fi322.323.IP "" 0324.325.P326This is somewhat annoying, so express re\-exports these middleware properties, however they are \fIidentical\fR:327.328.IP "" 4329.330.nf331332app\.use(express\.logger());333.334.fi335.336.IP "" 0337.338.SS "Error Handling"339Express provides the \fIapp\.error()\fR method which receives exceptions thrown within a route, or passed to \fInext(err)\fR\. Below is an example which serves different pages based on our ad\-hoc \fINotFound\fR exception:340.341.IP "" 4
22 unmodified lines
364.365.P366We can call \fIapp\.error()\fR several times as shown below\. Here we check for an instanceof \fINotFound\fR and show the 404 page, or we pass on to the next error handler\.367.368.P369Note that these handlers can be defined anywhere, as they will be placed below the route handlers on \fIlisten()\fR\. This allows for definition within \fIconfigure()\fR blocks so we can handle exceptions in different ways based on the environment\.370.371.IP "" 4372.373.nf374
34 unmodified lines
409.IP "" 4410.411.nf412378app\.use(connect\.errorHandler({ dumpExceptions: true }));413app\.use(express\.errorHandler({ dumpExceptions: true }));414.415.fi416.417.IP "" 0
4 unmodified lines
422.IP "" 4423.424.nf425391app\.use(connect\.errorHandler({ showStack: true, dumpExceptions: true }));426app\.use(express\.errorHandler({ showStack: true, dumpExceptions: true }));427.428.fi429.430.IP "" 0
1 unmodified line
432.P433The \fIerrorHandler\fR middleware also responds with \fIjson\fR if \fIAccept: application/json\fR is present, which is useful for developing apps that rely heavily on client\-side JavaScript\.434.435.SS "View Rendering"401View filenames take the form \fINAME\fR\.\fIENGINE\fR, where \fIENGINE\fR is the name of the module that will be required\. For example the view \fIlayout\.ejs\fR will tell the view system to \fIrequire(\'ejs\')\fR, the module being loaded must (currently) export the method \fIexports\.render(str, options)\fR to comply with Express, however with will likely be extensible in the future\.436View filenames take the form \fINAME\fR\.\fIENGINE\fR, where \fIENGINE\fR is the name of the module that will be required\. For example the view \fIlayout\.ejs\fR will tell the view system to \fIrequire(\'ejs\')\fR, the module being loaded must export the method \fIexports\.render(str, options)\fR to comply with Express, however \fIapp\.register()\fR can be used to map engines to file extensions, so that for example \"foo\.html\" can be rendered by jade\.437.438.P439Below is an example using Haml\.js \fIhttp://github\.com/visionmedia/haml\.js\fR to render \fIindex\.html\fR, and since we do not use \fIlayout: false\fR the rendered contents of \fIindex\.html\fR will be passed as the \fIbody\fR local variable in \fIlayout\.haml\fR\.440.
62 unmodified lines
503.fi504.505.IP "" 0506.507.P508Express also provides the \fIview options\fR setting, which is applied each time a view is rendered, so for example if you rarely use layouts you may set:509.510.IP "" 4511.512.nf513514app\.set(\'view options\', {515 layout: false516});517.518.fi519.520.IP "" 0521.522.P523Which can then be overridden within the \fBres\.render()\fR call if need be:524.525.IP "" 4526.527.nf528529res\.render(\'myview\.ejs\', { layout: true });530.531.fi532.533.IP "" 0534.535.P536A good example of this is specifying custom \fIejs\fR opening and closing tags:537.538.IP "" 4539.540.nf541542app\.set(\'view options\', {543 open: \'{{\',544 close: \'}}\'545});546.547.fi548.549.IP "" 0550.551.SS "View Partials"552The Express view system has built\-in support for partials and collections, which are sort of \"mini\" views representing a document fragment\. For example rather than iterating in a view to display comments, we would use a partial with collection support:553.554.IP "" 4
118 unmodified lines
673.674.IP "" 0675.676.P598To utilize urlencoded request bodies, \fIreq\.body\fR should be an object\. This can be done by using the \fIconnect\.bodyDecoder\fR middleware\.677To utilize urlencoded request bodies, \fIreq\.body\fR should be an object\. This can be done by using the \fIexpress\.bodyDecoder\fR middleware\.678.679.SS "req\.flash(type[, msg])"680Queue flash \fImsg\fR of the given \fItype\fR\.681.
472 unmodified lines
1154.fi1155.1156.IP "" 01157.1158.SS "app\.register(ext, exports)"1159Register the given template engine \fIexports\fR as \fIext\fR\. For example we may wish to map \"\.html\" files to jade:1160.1161.IP "" 41162.1163.nf11641165 app\.register(\'\.html\', require(\'jade\'));1166.1167.fi1168.1169.IP "" 01170.1171.P1172This is also useful for libraries that may not match extensions correctly\. For example my haml\.js library is installed from npm as \"hamljs\" so instead of layout\.hamljs, we can register the engine as \"\.haml\":1173.1174.IP "" 41175.1176.nf11771178 app\.register(\'\.haml\', require(\'haml\-js\'));1179.1180.fi1181.1182.IP "" 01183.1184.P1185For engines that do not comply with the Express specification, we can also wrap their api this way\.1186.1187.IP "" 41188.1189.nf11901191 app\.register(\'\.foo\', {1192 render: function(str, options) {1193 // perhaps their api is1194 // foo\.toHTML(str, options);1195 }1196 });1197.1198.fi1199.1200.IP "" 01201.1202.SS "app\.listen([port[, host]])"1203Bind the app server to the given \fIport\fR, which defaults to 3000\. When \fIhost\fR is omitted all connections will be accepted via \fIINADDR_ANY\fR\.1204.1205.IP "" 4
44 unmodified lines
modified:docs/guide.html+81 added-16 removed
211 unmodified lines
212<li><a href="#app-error-function-">app.error()</a></li>213<li><a href="#app-helpers-obj-">app.helpers()</a></li>214<li><a href="#app-dynamicHelpers-obj-">app.dynamicHelpers()</a></li>215<li><a href="#app-mounted-fn-">app.mounted()</a></li>216<li><a href="#app-register-ext-exports-">app.register()</a></li>217<li><a href="#app-listen-port-host-">app.listen()</a></li>218</ul>219 <a href='http://github.com/visionmedia/express' id='logo'>Express</a> 220 <p id="tagline">
53 unmodified lines
274Note the use of <em>app.router</em>, which can (optionally) be used to mount the application routes,275otherwise the first call to <em>app.{get,put,del,post}()</em> will mount the routes.</p>276277<pre><code>app.configure(function(){277 app.use(connect.methodOverride());278 app.use(connect.bodyDecoder());278 app.use(express.methodOverride());279 app.use(express.bodyDecoder());280 app.use(app.router);280 app.use(connect.staticProvider(__dirname + '/public'));281 app.use(express.staticProvider(__dirname + '/public'));282});283284app.configure('development', function(){284 app.use(connect.errorHandler({ dumpExceptions: true, showStack: true }));285 app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));286});287288app.configure('production', function(){288 app.use(connect.errorHandler());289 app.use(express.errorHandler());290});291</code></pre>292293<p>For internal and arbitrary settings Express provides the <em>set(key[, val])</em>, <em>enable(key)</em>, <em>disable(key)</em> methods:</p>
25 unmodified lines
319<li><em>env</em> Application environment set internally, use <em>app.set('env')</em> on <em>Server#listen()</em></li>320<li><em>home</em> Application base path used for <em>res.redirect()</em> and transparently handling mounted apps.</li>321<li><em>views</em> Root views directory defaulting to <strong>CWD/views</strong></li>322<li><em>view engine</em> Default view engine name for views rendered without extensions</li>323<li><em>view options</em> An object specifying global view options</li>324<li><em>partials</em> Root view partials directory defaulting to <em>views</em>/partials.</li>325</ul>326327328<h3 id="Routing">Routing</h3>
90 unmodified lines
419420<p>The Express <em>Plugin</em> is no more! middleware via <a href="http://github.com/extjs/Connect">Connect</a> can be421passed to <em>express.createServer()</em> as you would with a regular Connect server. For example:</p>422420<pre><code>var connect = require('connect'),421 express = require('express');423<pre><code>var express = require('express');424425var app = express.createServer(424 connect.logger(),425 connect.bodyDecoder()426 express.logger(),427 express.bodyDecoder()428);429</code></pre>430431<p>Alternatively we can <em>use()</em> them which is useful when adding middleware within <em>configure()</em> blocks:</p>432431<pre><code>app.use(connect.logger({ format: ':method :uri' }));433<pre><code>app.use(express.logger({ format: ':method :uri' }));434</code></pre>435436<p>Typically with connect middleware you would <em>require('connect')</em> like so:</p>437438<pre><code>var connect = require('connect');439app.use(connect.logger());440</code></pre>441442<p>This is somewhat annoying, so express re-exports these middleware properties, however they are <em>identical</em>:</p>443444<pre><code>app.use(express.logger());445</code></pre>446447<h3 id="Error-Handling">Error Handling</h3>448449<p>Express provides the <em>app.error()</em> method which receives exceptions thrown within a route,450or passed to <em>next(err)</em>. Below is an example which serves different pages based on our
19 unmodified lines
470<p>We can call <em>app.error()</em> several times as shown below.471Here we check for an instanceof <em>NotFound</em> and show the472404 page, or we pass on to the next error handler.</p>473474<p>Note that these handlers can be defined anywhere, as they475will be placed below the route handlers on <em>listen()</em>. This476allows for definition within <em>configure()</em> blocks so we can477handle exceptions in different ways based on the environment.</p>478479<pre><code>app.error(function(err, req, res, next){480 if (err instanceof NotFound) {481 res.render('404.jade');482 } else {
17 unmodified lines
500<p>Our apps could also utilize the Connect <em>errorHandler</em> middleware501to report on exceptions. For example if we wish to output exceptions502in "development" mode to <em>stderr</em> we can use:</p>503486<pre><code>app.use(connect.errorHandler({ dumpExceptions: true }));504<pre><code>app.use(express.errorHandler({ dumpExceptions: true }));505</code></pre>506507<p>Also during development we may want fancy html pages to show exceptions508that are passed or thrown, so we can set <em>showStack</em> to true:</p>509492<pre><code>app.use(connect.errorHandler({ showStack: true, dumpExceptions: true }));510<pre><code>app.use(express.errorHandler({ showStack: true, dumpExceptions: true }));511</code></pre>512513<p>The <em>errorHandler</em> middleware also responds with <em>json</em> if <em>Accept: application/json</em>514is present, which is useful for developing apps that rely heavily on client-side JavaScript.</p>
1 unmodified line
516<h3 id="View-Rendering">View Rendering</h3>517518<p>View filenames take the form <em>Express</em>.<em>ENGINE</em>, where <em>ENGINE</em> is the name519of the module that will be required. For example the view <em>layout.ejs</em> will502tell the view system to <em>require('ejs')</em>, the module being loaded must (currently)503export the method <em>exports.render(str, options)</em> to comply with Express, however504with will likely be extensible in the future.</p>520tell the view system to <em>require('ejs')</em>, the module being loaded must export the method <em>exports.render(str, options)</em> to comply with Express, however521<em>app.register()</em> can be used to map engines to file extensions, so that for example "foo.html" can be rendered by jade.</p>522523<p>Below is an example using <a href="http://github.com/visionmedia/haml.js">Haml.js</a> to render <em>index.html</em>,524and since we do not use <em>layout: false</em> the rendered contents of <em>index.html</em> will be passed as525the <em>body</em> local variable in <em>layout.haml</em>.</p>
26 unmodified lines
552553<pre><code>res.render('another-page.ejs');554</code></pre>555556<p>Express also provides the <em>view options</em> setting, which is applied each time a view is rendered, so for example if you rarely use layouts you may set:</p>557558<pre><code>app.set('view options', {559 layout: false560});561</code></pre>562563<p>Which can then be overridden within the <code>res.render()</code> call if need be:</p>564565<pre><code>res.render('myview.ejs', { layout: true });566</code></pre>567568<p>A good example of this is specifying custom <em>ejs</em> opening and closing tags:</p>569570<pre><code>app.set('view options', {571 open: '{{',572 close: '}}'573});574</code></pre>575576<h3 id="View-Partials">View Partials</h3>577578<p>The Express view system has built-in support for partials and collections, which are579sort of "mini" views representing a document fragment. For example rather than iterating
81 unmodified lines
661662663<p>To utilize urlencoded request bodies, <em>req.body</em>664should be an object. This can be done by using628the <em>connect.bodyDecoder</em> middleware.</p>665the <em>express.bodyDecoder</em> middleware.</p>666667<h3 id="req-flash-type-msg-">req.flash(type[, msg])</h3>668669<p>Queue flash <em>msg</em> of the given <em>type</em>.</p>
304 unmodified lines
974975app.use(blog);976</code></pre>977978<h3 id="app-register-ext-exports-">app.register(ext, exports)</h3>979980<p>Register the given template engine <em>exports</em>981as <em>ext</em>. For example we may wish to map ".html"982files to jade:</p>983984<pre><code> app.register('.html', require('jade'));985</code></pre>986987<p>This is also useful for libraries that may not988match extensions correctly. For example my haml.js989library is installed from npm as "hamljs" so instead990of layout.hamljs, we can register the engine as ".haml":</p>991992<pre><code> app.register('.haml', require('haml-js'));993</code></pre>994995<p>For engines that do not comply with the Express996specification, we can also wrap their api this way.</p>997998<pre><code> app.register('.foo', {999 render: function(str, options) {1000 // perhaps their api is1001 // foo.toHTML(str, options);1002 }1003 });1004</code></pre>10051006<h3 id="app-listen-port-host-">app.listen([port[, host]])</h3>10071008<p>Bind the app server to the given <em>port</em>, which defaults to 3000. When <em>host</em> is omitted all1009connections will be accepted via <em>INADDR_ANY</em>.</p>
28 unmodified lines
modified:docs/guide.md+27 added-3 removed
261 unmodified lines
262### View Rendering263264View filenames take the form _NAME_._ENGINE_, where _ENGINE_ is the name265of the module that will be required. For example the view _layout.ejs_ will266tell the view system to _require('ejs')_, the module being loaded must (currently)267export the method _exports.render(str, options)_ to comply with Express, however 268with will likely be extensible in the future.266tell the view system to _require('ejs')_, the module being loaded must export the method _exports.render(str, options)_ to comply with Express, however 267_app.register()_ can be used to map engines to file extensions, so that for example "foo.html" can be rendered by jade.268269Below is an example using [Haml.js](http://github.com/visionmedia/haml.js) to render _index.html_,270and since we do not use _layout: false_ the rendered contents of _index.html_ will be passed as 271the _body_ local variable in _layout.haml_.
390 unmodified lines
662 });663 664 app.use(blog);665666### app.register(ext, exports)667668Register the given template engine _exports_669as _ext_. For example we may wish to map ".html"670files to jade:671672 app.register('.html', require('jade'));673674This is also useful for libraries that may not675match extensions correctly. For example my haml.js676library is installed from npm as "hamljs" so instead677of layout.hamljs, we can register the engine as ".haml":678679 app.register('.haml', require('haml-js'));680681For engines that do not comply with the Express682specification, we can also wrap their api this way.683684 app.register('.foo', {685 render: function(str, options) {686 // perhaps their api is687 // foo.toHTML(str, options);688 }689 });690691### app.listen([port[, host]])692693Bind the app server to the given _port_, which defaults to 3000. When _host_ is omitted all694connections will be accepted via _INADDR_ANY_.
19 unmodified lines
modified:docs/index.1+7 added-1 removed
1.\" generated with Ronn/v0.6.62.\" http://github.com/rtomayko/ronn/3.4.TH "INDEX" "" "July 2010" "" ""4.TH "INDEX" "" "August 2010" "" ""5.6.IP "" 47.8.nf
21 unmodified lines
30.IP "\(bu" 431Dynamic view helpers32.33.IP "\(bu" 434Application level view options35.36.IP "\(bu" 437Content negotiation38.39.IP "\(bu" 440Focus on high performance
82 unmodified lines
123.124.IP "\(bu" 4125Storify \fIhttp://storify\.com\fR \- The future of publishing126.127.IP "\(bu" 4128Ogre \fIhttp://ogre\.adc4gis\.com/\fR \- Translates spatial files into GeoJSON129.130.IP "" 0131
modified:docs/index.html+2 added
204 unmodified lines
205<ul>206<li>Robust routing</li>207<li>Redirection helpers</li>208<li>Dynamic view helpers</li>209<li>Application level view options</li>210<li>Content negotiation</li>211<li>Focus on high performance</li>212<li>View rendering and partials support</li>213<li>Environment based configuration</li>
38 unmodified lines
252<li><a href="http://codeshelver.com/">Code Shelver</a> - GitHub watch list app</li>253<li><a href="http://clickdummy.net/">Clickdummy</a> - Fast prototyping for designers</li>254<li><a href="http://e-resistible.co.uk">E-Resistible</a> - Online takeaway ordering app</li>255<li><a href="http://storify.com">Storify</a> - The future of publishing</li>256<li><a href="http://ogre.adc4gis.com/">Ogre</a> - Translates spatial files into GeoJSON</li>257</ul>258259260</div>
4 unmodified lines
modified:docs/migrate.1+7 added-10 removed
1.\" generated with Ronn/v0.6.62.\" http://github.com/rtomayko/ronn/3.4.TH "MIGRATE" "" "July 2010" "" ""4.TH "MIGRATE" "" "August 2010" "" ""5.6.SS "Built On Connect"7Express 1\.x is written to run on\-top of the Connect \fIhttp://extjs\.github\.com/Connect\fR middlware framework, thus the \fIPlugin\fR has been replaced by Connect\'s middleware\. By abstracting our middleware to Connect we allow additional community frameworks to develop robust, high\-level frameworks using the same technologies as Express\.8.
64 unmodified lines
73.IP "" 474.75.nf7677var connect = require(\'connect\');7877var app = express\.createServer(80 connect\.logger(),81 connect\.methodOverride(),82 connect\.cookieDecoder()78 express\.logger(),79 express\.methodOverride(),80 express\.cookieDecoder()81);82.83.fi84.
5 unmodified lines
90.IP "" 491.92.nf9396var connect = require(\'connect\');94var app = express\.createServer();9599app\.use(connect\.logger());100app\.use(connect\.methodOverride());101app\.use(connect\.cookieDecoder());96app\.use(express\.logger());97app\.use(express\.methodOverride());98app\.use(express\.cookieDecoder());99.100.fi101.102.IP "" 0
242 unmodified lines
modified:docs/migrate.html+8 added-11 removed
244 unmodified lines
245</code></pre>246247<p>Which we can now <em>use()</em> within our app, or pass to the <em>express.createServer()</em> method:</p>248249<pre><code>var connect = require('connect');250251var app = express.createServer(252 connect.logger(),253 connect.methodOverride(),254 connect.cookieDecoder()249<pre><code>var app = express.createServer(250 express.logger(),251 express.methodOverride(),252 express.cookieDecoder()253);254</code></pre>255256<p>or:</p>257260<pre><code>var connect = require('connect');261var app = express.createServer();258<pre><code>var app = express.createServer();259263app.use(connect.logger());264app.use(connect.methodOverride());265app.use(connect.cookieDecoder());260app.use(express.logger());261app.use(express.methodOverride());262app.use(express.cookieDecoder());263</code></pre>264265<p>For documentation on creating Connect middleware visit <a href="http://extjs.github.com/Connect/#Middleware-Authoring">Middleware Authoring</a>.</p>266
142 unmodified lines