Skip to content
Myr

Rebuilt 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 5297966 · Browse files · 4 files+133 added−21 removed
This commit

State

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

Diff stats

4 files+133 added−21 removed

  • other:+133 added−21 removed

4 files+133 added−21 removed

modified:docs/api.html+79 added-16 removed
611 unmodified lines
612 <span class="this">this</span>.<span class="variable">viewHelpers</span> = {};613 <span class="this">this</span>.<span class="variable">dynamicViewHelpers</span> = {};614 <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> || []);615616 <span class="comment">// Default &quot;home&quot; to / </span>617 <span class="this">this</span>.<span class="variable">set</span>(<span class="string">'home'</span>, <span class="string">'/'</span>);618619 <span class="comment">// Set &quot;env&quot; to {EXPRESS,CONNECT}_ENV</span>620 <span class="this">this</span>.<span class="variable">set</span>(<span class="string">'env'</span>, <span class="variable">process</span>.<span class="variable">env</span>.<span class="class">EXPRESS_ENV</span> || <span class="variable">process</span>.<span class="variable">connectEnv</span>.<span class="variable">name</span>);621622 <span class="comment">// Expose objects to each other</span>623 <span class="this">this</span>.<span class="variable">use</span>(<span class="keyword">function</span>(<span class="variable">req</span>, <span class="variable">res</span>, <span class="variable">next</span>){624 <span class="variable">req</span>.<span class="variable">params</span> = <span class="variable">req</span>.<span class="variable">params</span> || {};625 <span class="variable">req</span>.<span class="variable">params</span>.<span class="variable">get</span> = {};
11 unmodified lines
637 <span class="variable">next</span>();638 });639640 <span class="comment">// Use router, expose as app.get(), etc</span>635 <span class="this">this</span>.<span class="variable">router</span> = <span class="variable">router</span>(<span class="keyword">function</span>(<span class="variable">app</span>){ <span class="variable">self</span>.<span class="variable">routes</span> = <span class="variable">app</span>; });641 <span class="keyword">var</span> <span class="variable">fn</span> = <span class="variable">router</span>(<span class="keyword">function</span>(<span class="variable">app</span>){ <span class="variable">self</span>.<span class="variable">routes</span> = <span class="variable">app</span>; });642 <span class="this">this</span>.<span class="variable">__defineGetter__</span>(<span class="string">'router'</span>, <span class="keyword">function</span>(){643 <span class="this">this</span>.<span class="variable">__usedRouter</span> = <span class="variable">true</span>;644 <span class="keyword">return</span> <span class="variable">fn</span>;645 });646};</code></pre>647</td>648</tr>649<tr class="code">
14 unmodified lines
664<ul><li><p><strong>param</strong>: <em>Number</em> port</p></li><li><p><strong>param</strong>: <em>String</em> host</p></li><li><p><strong>api</strong>: <em>public</em></p></li></ul>665</td>666<td class="code">667<pre><code><span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">listen</span> = <span class="keyword">function</span>(<span class="variable">port</span>, <span class="variable">host</span>){658 <span class="comment">// Default &quot;home&quot; to the mounted route or '/'</span>659 <span class="keyword">if</span> (!<span class="this">this</span>.<span class="variable">set</span>(<span class="string">'home'</span>)) {660 <span class="this">this</span>.<span class="variable">set</span>(<span class="string">'home'</span>, <span class="this">this</span>.<span class="variable">route</span> || <span class="string">'/'</span>);661 }662663 <span class="comment">// Set &quot;env&quot; to {EXPRESS,CONNECT}_ENV</span>664 <span class="this">this</span>.<span class="variable">set</span>(<span class="string">'env'</span>, <span class="variable">process</span>.<span class="variable">env</span>.<span class="class">EXPRESS_ENV</span> || <span class="variable">process</span>.<span class="variable">connectEnv</span>.<span class="variable">name</span>);665 <span class="this">this</span>.<span class="variable">runConfig</span>(<span class="string">'any'</span>, <span class="this">this</span>.<span class="variable">set</span>(<span class="string">'env'</span>));666668 <span class="comment">// Setup view reloading</span>669 <span class="keyword">if</span> (<span class="this">this</span>.<span class="variable">set</span>(<span class="string">'reload views'</span>)) {670 <span class="variable">view</span>.<span class="variable">watcher</span>.<span class="variable">call</span>(<span class="this">this</span>, <span class="this">this</span>.<span class="variable">set</span>(<span class="string">'reload views'</span>));671 }671672 <span class="variable">connect</span>.<span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">listen</span>.<span class="variable">call</span>(<span class="this">this</span>, <span class="variable">port</span>, <span class="variable">host</span>);673};</code></pre>674</td>675</tr>676<tr class="code">677<td class="docs">678<p>Proxy <code>connect.Server#use()</code> to apply settings to679mounted applications.</p>680681<h2></h2>682683<ul><li><p><strong>param</strong>: <em>String | Function | Server</em> route</p></li><li><p><strong>param</strong>: <em>Function | Server</em> middleware</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>684</td>685<td class="code">686<pre><code><span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">use</span> = <span class="keyword">function</span>(<span class="variable">route</span>, <span class="variable">middleware</span>){687 <span class="keyword">if</span> (<span class="keyword">typeof</span> <span class="variable">route</span> !== <span class="string">'string'</span>) {688 <span class="variable">middleware</span> = <span class="variable">route</span>, <span class="variable">route</span> = <span class="string">'/'</span>;689 }690691 <span class="variable">connect</span>.<span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">use</span>.<span class="variable">call</span>(<span class="this">this</span>, <span class="variable">route</span>, <span class="variable">middleware</span>);692693 <span class="comment">// Mounted an app</span>694 <span class="keyword">if</span> (<span class="variable">middleware</span> <span class="variable">instanceof</span> <span class="class">Server</span>) {695 <span class="comment">// Home is /:route/:home</span>696 <span class="keyword">var</span> <span class="variable">app</span> = <span class="variable">middleware</span>,697 <span class="variable">home</span> = <span class="variable">app</span>.<span class="variable">set</span>(<span class="string">'home'</span>);698 <span class="keyword">if</span> (<span class="variable">home</span> === <span class="string">'/'</span>) <span class="variable">home</span> = <span class="string">''</span>;699 <span class="variable">app</span>.<span class="variable">set</span>(<span class="string">'home'</span>, (<span class="variable">app</span>.<span class="variable">route</span> || <span class="string">''</span>) + <span class="variable">home</span>);700 <span class="comment">// Mounted hook</span>701 <span class="keyword">if</span> (<span class="variable">app</span>.<span class="variable">__mounted</span>) <span class="variable">app</span>.<span class="variable">__mounted</span>.<span class="variable">call</span>(<span class="variable">app</span>, <span class="this">this</span>);702 }703704 <span class="keyword">return</span> <span class="this">this</span>;705};</code></pre>706</td>707</tr>708<tr class="code">709<td class="docs">710<p>Assign a callback <code>fn</code> which is called711when this <code>Server</code> is passed to <code>Server#use()</code>.</p>712713<h2>Examples</h2>714715<p> var app = express.createServer(),716 blog = express.createServer();</p>717718<p> blog.mounted(function(parent){719 // parent is app720 // "this" is blog721 });</p>722723<p> app.use(blog);</p>724725<h2></h2>726727<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>728</td>729<td class="code">730<pre><code><span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">mounted</span> = <span class="keyword">function</span>(<span class="variable">fn</span>){731 <span class="this">this</span>.<span class="variable">__mounted</span> = <span class="variable">fn</span>;732 <span class="keyword">return</span> <span class="this">this</span>;733};</code></pre>734</td>735</tr>736<tr class="code">737<td class="docs">738<p>Register the given view helpers <code>obj</code>. This method739can be called several times to apply additional helpers.</p>740741<h2></h2>
103 unmodified lines
845</td>846</tr>847<tr class="code">848<td class="docs">789<p>Disable <code>setting</code>.</p>849<p>Configure callback for the given <code>env</code>.</p>850851<h2></h2>852793<ul><li><p><strong>param</strong>: <em>String</em> setting</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>853<ul><li><p><strong>param</strong>: <em>String</em> env</p></li><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>854</td>855<td class="code">856<pre><code><span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">configure</span> = <span class="keyword">function</span>(<span class="variable">env</span>, <span class="variable">fn</span>){797 <span class="keyword">if</span> (<span class="keyword">typeof</span> <span class="variable">env</span> === <span class="string">'function'</span>) <span class="variable">fn</span> = <span class="variable">env</span>, <span class="variable">env</span> = <span class="string">'any'</span>;798 (<span class="this">this</span>.<span class="variable">config</span>[<span class="variable">env</span>] = <span class="this">this</span>.<span class="variable">config</span>[<span class="variable">env</span>] || []).<span class="variable">push</span>(<span class="variable">fn</span>);857 <span class="keyword">if</span> (<span class="keyword">typeof</span> <span class="variable">env</span> === <span class="string">'function'</span>) {858 <span class="variable">fn</span> = <span class="variable">env</span>, <span class="variable">env</span> = <span class="string">'all'</span>;859 }860 <span class="keyword">if</span> (<span class="variable">env</span> === <span class="string">'all'</span> || <span class="this">this</span>.<span class="variable">set</span>(<span class="string">'env'</span>) === <span class="variable">env</span>) {861 <span class="variable">fn</span>.<span class="variable">call</span>(<span class="this">this</span>);862 }863 <span class="keyword">return</span> <span class="this">this</span>;864};865866<span class="comment">// Generate routing methods</span>
1 unmodified line
868(<span class="keyword">function</span>(<span class="variable">method</span>){869 <span class="class">Server</span>.<span class="variable">prototype</span>[<span class="variable">method</span>] = <span class="keyword">function</span>(<span class="variable">path</span>, <span class="variable">fn</span>){870 <span class="keyword">if</span> (!<span class="this">this</span>.<span class="variable">__usedRouter</span>) {871 <span class="this">this</span>.<span class="variable">use</span>(<span class="this">this</span>.<span class="variable">router</span>);808 <span class="this">this</span>.<span class="variable">__usedRouter</span> = <span class="variable">true</span>;872 }873 <span class="this">this</span>.<span class="variable">routes</span>[<span class="variable">method</span>](<span class="variable">path</span>, <span class="variable">fn</span>);874 <span class="keyword">return</span> <span class="this">this</span>;875 };
279 unmodified lines
modified:docs/guide.1+22 added-1 removed
132 unmodified lines
133.IP "\(bu" 4134\fIenv\fR Application environment set internally, use \fIapp\.set(\'env\')\fR on \fIServer#listen()\fR135.136.IP "\(bu" 4137\fIhome\fR Application base path used with \fIres\.redirect()\fR, when mounted defaults to \fIServer#route\fR, otherwise \"/\"\. Assigned on \fIServer#listen()\fR\.137\fIhome\fR Application base path used with \fIres\.redirect()\fR, when mounted defaults to \fIServer#route\fR, otherwise \"/\"\.138.139.IP "\(bu" 4140\fIviews\fR Root views directory defaulting to \fBCWD/views\fR141.
916 unmodified lines
1058.fi1059.1060.IP "" 01061.1062.SS "app\.mounted(fn)"1063Assign a callback \fIfn\fR which is called when this \fIServer\fR is passed to \fIServer#use()\fR\.1064.1065.IP "" 41066.1067.nf10681069var app = express\.createServer(),1070 blog = express\.createServer();10711072blog\.mounted(function(parent){1073 // parent is app1074 // \"this\" is blog1075});10761077app\.use(blog);1078.1079.fi1080.1081.IP "" 01082.1083.SS "app\.listen([port[, host]])"1084Bind 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\.1085.1086.IP "" 4
44 unmodified lines
modified:docs/guide.html+17 added-2 removed
210 unmodified lines
211<li><a href="#app-redirect-name-val-">app.redirect()</a></li>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-listen-port-host-">app.listen()</a></li>217</ul>218 <a href='http://github.com/visionmedia/express' id='logo'>Express</a> 219 <p id="tagline">
92 unmodified lines
312<p>Express supports the following settings out of the box:</p>313314<ul>315<li><em>env</em> Application environment set internally, use <em>app.set('env')</em> on <em>Server#listen()</em></li>315<li><em>home</em> Application base path used with <em>res.redirect()</em>, when mounted defaults316to <em>Server#route</em>, otherwise "/". Assigned on <em>Server#listen()</em>.</li>316<li><em>home</em> Application base path used with <em>res.redirect()</em>, when mounted defaults to <em>Server#route</em>, otherwise "/".</li>317<li><em>views</em> Root views directory defaulting to <strong>CWD/views</strong></li>318<li><em>view engine</em> Default view engine name for views rendered without extensions</li>319<li><em>reload views</em> Reloads altered views, by default watches for <em>mtime</em> changes with320 with a 5 minute interval. Example: <em>app.set('reload views', 60000);</em></li>
599 unmodified lines
920921<pre><code>&lt;%= session.name %&gt;922</code></pre>923924<h3 id="app-mounted-fn-">app.mounted(fn)</h3>925926<p>Assign a callback <em>fn</em> which is called when this <em>Server</em> is passed to <em>Server#use()</em>.</p>927928<pre><code>var app = express.createServer(),929 blog = express.createServer();930931blog.mounted(function(parent){932 // parent is app933 // "this" is blog934});935936app.use(blog);937</code></pre>938939<h3 id="app-listen-port-host-">app.listen([port[, host]])</h3>940941<p>Bind the app server to the given <em>port</em>, which defaults to 3000. When <em>host</em> is omitted all942connections will be accepted via <em>INADDR_ANY</em>.</p>
28 unmodified lines
modified:docs/guide.md+15 added-2 removed
75 unmodified lines
7677Express supports the following settings out of the box:7879 * _env_ Application environment set internally, use _app.set('env')_ on _Server#listen()_80 * _home_ Application base path used with _res.redirect()_, when mounted defaults81 to _Server#route_, otherwise "/". Assigned on _Server#listen()_.80 * _home_ Application base path used with _res.redirect()_, when mounted defaults to _Server#route_, otherwise "/".81 * _views_ Root views directory defaulting to **CWD/views**82 * _view engine_ Default view engine name for views rendered without extensions83 * _reload views_ Reloads altered views, by default watches for _mtime_ changes with84 with a 5 minute interval. Example: _app.set('reload views', 60000);_
530 unmodified lines
615All views would now have _session_ available so that session data can be accessed via _session.name_ etc:616617 <%= session.name %>618619### app.mounted(fn)620621Assign a callback _fn_ which is called when this _Server_ is passed to _Server#use()_.622623 var app = express.createServer(),624 blog = express.createServer();625 626 blog.mounted(function(parent){627 // parent is app628 // "this" is blog629 });630 631 app.use(blog);632633### app.listen([port[, host]])634635Bind the app server to the given _port_, which defaults to 3000. When _host_ is omitted all636connections will be accepted via _INADDR_ANY_.
19 unmodified lines