Moved config docs up
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 cb04364 · Browse files · 3 files·+162 added−158 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+162 added−158 removed
- other:+162 added−158 removed
Provenance
- Commit
6e8413f- Tree
1883052- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
cb04364
3 files changed+162 added−158 removed
modified:docs/guide.1+63 added-63 removed
1 unmodified line2 .\" http://github.com/rtomayko/ronn/3 .4 .TH "GUIDE" "" "July 2010" "" ""5 .6-.SS "First Application"7-The \fIexpress\.Server\fR now inherits from \fIhttp\.Server\fR, however follows the same idiom by providing \fIexpress\.createServer()\fR as shown below:6+.SS "Hello World"7+The \fIexpress\.Server\fR now inherits from \fIhttp\.Server\fR, however follows the same idiom by providing \fIexpress\.createServer()\fR as shown below\. This means that you can utilize Express server\'s transparently with other libraries\.8 .9 .IP "" 410 .11 .nf9 unmodified lines21 .fi22 .23 .IP "" 024 .25+.SS "Configuration"26+Express supports arbitrary environments, such as \fIproduction\fR and \fIdevelopment\fR\. Developers can use the \fIconfigure()\fR method to setup needs required by the current environment\. When \fIconfigure()\fR is called without an environment name it will be run in \fIevery\fR environment prior to the environment specific callback\.27+.28+.P29+In the example below we only \fIdumpExceptions\fR, and respond with exception stack traces in \fIdevelopment\fR mode, however for both environments we utilize \fImethodOverride\fR and \fIbodyDecoder\fR\.30+.31+.IP "" 432+.33+.nf34+35+app\.configure(function(){36+ app\.use(\'/\', connect\.methodOverride());37+ app\.use(\'/\', connect\.bodyDecoder());38+});39+40+app\.configure(\'development\', function(){41+ app\.use(\'/\', connect\.errorHandler({ dumpExceptions: true, showStack: true }));42+});43+44+app\.configure(\'production\', function(){45+ app\.use(\'/\', connect\.errorHandler());46+});47+.48+.fi49+.50+.IP "" 051+.52+.P53+For internal and arbitrary settings Express provides the \fIset(key[, val])\fR, \fIenable(key)\fR, \fIdisable(key)\fR methods:54+.55+.IP "" 456+.57+.nf58+59+app\.configure(function(){60+ app\.set(\'views\', __dirname + \'/views\');61+ app\.set(\'views\');62+ // => \"\.\.\. views directory \.\.\.\"63+64+ app\.enable(\'some feature\');65+ // same as app\.set(\'some feature\', true);66+67+ app\.disable(\'some feature\');68+ // same as app\.set(\'some feature\', false);69+});70+.71+.fi72+.73+.IP "" 074+.75+.SS "Settings"76+Express supports the following settings out of the box:77+.78+.IP "\(bu" 479+\fIviews\fR Root views directory defaulting to \fBCWD/views\fR80+.81+.IP "\(bu" 482+\fIview engine\fR Default view engine name for views rendered without extensions83+.84+.IP "" 085+.86 .SS "Routing"87 Express 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 passed as the \fIthird\fR argument, which here we name \fIparams\fR\.88 .89 .IP "" 4114 unmodified lines204 .205 .fi206 .207 .IP "" 0147-.148-.SS "Configuration"149-Express supports arbitrary environments, such as \fIproduction\fR and \fIdevelopment\fR\. Developers can use the \fIconfigure()\fR method to setup needs required by the current environment\. When \fIconfigure()\fR is called without an environment name it will be run in \fIevery\fR environment prior to the environment specific callback\.150-.151-.P152-In the example below we only \fIdumpExceptions\fR, and respond with exception stack traces in \fIdevelopment\fR mode, however for both environments we utilize \fImethodOverride\fR and \fIbodyDecoder\fR\.153-.154-.IP "" 4155-.156-.nf208 158-app\.configure(function(){159- app\.use(\'/\', connect\.methodOverride());160- app\.use(\'/\', connect\.bodyDecoder());161-});162-163-app\.configure(\'development\', function(){164- app\.use(\'/\', connect\.errorHandler({ dumpExceptions: true, showStack: true }));165-});166-167-app\.configure(\'production\', function(){168- app\.use(\'/\', connect\.errorHandler());169-});170-.171-.fi172-.173-.IP "" 0174-.175-.P176-For internal and arbitrary settings Express provides the \fIset(key[, val])\fR, \fIenable(key)\fR, \fIdisable(key)\fR methods:177-.178-.IP "" 4179-.180-.nf181-182-app\.configure(function(){183- app\.set(\'views\', __dirname + \'/views\');184- app\.set(\'views\');185- // => \"\.\.\. views directory \.\.\.\"186-187- app\.enable(\'some feature\');188- // same as app\.set(\'some feature\', true);189-190- app\.disable(\'some feature\');191- // same as app\.set(\'some feature\', false);192-});193-.194-.fi195-.196-.IP "" 0197-.198-.SS "Settings"199-Express supports the following settings out of the box:200-.201-.IP "\(bu" 4202-\fIviews\fR Root views directory defaulting to \fBCWD/views\fR203-.204-.IP "\(bu" 4205-\fIview engine\fR Default view engine name for views rendered without extensions206-.207-.IP "" 0208-modified:docs/guide.html+52 added-51 removed
158 unmodified lines159 <li><a href="guide.html">Guide</a></li>160 <li><a href="migrate.html">1.x Migration</a></li>161 </ul>162 <div class='mp'>163-<h3 id="First-Application">First Application</h3>163+<h3 id="Hello-World">Hello World</h3>164 165 <p>The <em>express.Server</em> now inherits from <em>http.Server</em>, however166-follows the same idiom by providing <em>express.createServer()</em> as shown below:</p>166+follows the same idiom by providing <em>express.createServer()</em> as shown below. This means167+that you can utilize Express server's transparently with other libraries.</p>168 169 <pre><code>var app = require('express').createServer();170 171 app.get('/', function(req, res){2 unmodified lines174 175 app.listen(3000);176 </code></pre>177 178+<h3 id="Configuration">Configuration</h3>179+180+<p>Express supports arbitrary environments, such as <em>production</em> and <em>development</em>. Developers181+can use the <em>configure()</em> method to setup needs required by the current environment. When182+<em>configure()</em> is called without an environment name it will be run in <em>every</em> environment183+prior to the environment specific callback.</p>184+185+<p>In the example below we only <em>dumpExceptions</em>, and respond with exception stack traces186+in <em>development</em> mode, however for both environments we utilize <em>methodOverride</em> and <em>bodyDecoder</em>.</p>187+188+<pre><code>app.configure(function(){189+ app.use('/', connect.methodOverride());190+ app.use('/', connect.bodyDecoder());191+});192+193+app.configure('development', function(){194+ app.use('/', connect.errorHandler({ dumpExceptions: true, showStack: true }));195+});196+197+app.configure('production', function(){198+ app.use('/', connect.errorHandler());199+});200+</code></pre>201+202+<p>For internal and arbitrary settings Express provides the <em>set(key[, val])</em>, <em>enable(key)</em>, <em>disable(key)</em> methods:</p>203+204+<pre><code>app.configure(function(){205+ app.set('views', __dirname + '/views');206+ app.set('views');207+ // => "... views directory ..."208+209+ app.enable('some feature');210+ // same as app.set('some feature', true);211+212+ app.disable('some feature');213+ // same as app.set('some feature', false);214+});215+</code></pre>216+217+<h3 id="Settings">Settings</h3>218+219+<p>Express supports the following settings out of the box:</p>220+221+<ul>222+<li><em>views</em> Root views directory defaulting to <strong>CWD/views</strong></li>223+<li><em>view engine</em> Default view engine name for views rendered without extensions</li>224+</ul>225+226+227 <h3 id="Routing">Routing</h3>228 229 <p>Express utilizes the HTTP verbs to provide a meaningful, expressive routing API.230 For example we may want to render a user's account for the path <em>/user/12</em>, this80 unmodified lines311 connect.bodyDecoder()312 );313 </code></pre>314 265-<h3 id="Configuration">Configuration</h3>266-267-<p>Express supports arbitrary environments, such as <em>production</em> and <em>development</em>. Developers268-can use the <em>configure()</em> method to setup needs required by the current environment. When269-<em>configure()</em> is called without an environment name it will be run in <em>every</em> environment270-prior to the environment specific callback.</p>271-272-<p>In the example below we only <em>dumpExceptions</em>, and respond with exception stack traces273-in <em>development</em> mode, however for both environments we utilize <em>methodOverride</em> and <em>bodyDecoder</em>.</p>274-275-<pre><code>app.configure(function(){276- app.use('/', connect.methodOverride());277- app.use('/', connect.bodyDecoder());278-});279-280-app.configure('development', function(){281- app.use('/', connect.errorHandler({ dumpExceptions: true, showStack: true }));282-});283-284-app.configure('production', function(){285- app.use('/', connect.errorHandler());286-});287-</code></pre>288-289-<p>For internal and arbitrary settings Express provides the <em>set(key[, val])</em>, <em>enable(key)</em>, <em>disable(key)</em> methods:</p>290-291-<pre><code>app.configure(function(){292- app.set('views', __dirname + '/views');293- app.set('views');294- // => "... views directory ..."295-296- app.enable('some feature');297- // same as app.set('some feature', true);298-299- app.disable('some feature');300- // same as app.set('some feature', false);301-});302-</code></pre>303-304-<h3 id="Settings">Settings</h3>305-306-<p>Express supports the following settings out of the box:</p>307-308-<ul>309-<li><em>views</em> Root views directory defaulting to <strong>CWD/views</strong></li>310-<li><em>view engine</em> Default view engine name for views rendered without extensions</li>311-</ul>312-313-315 </div>316 </div>317 </div>318 </body>1 unmodified linemodified:docs/guide.md+47 added-44 removed
1223455678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626374 unmodified lines1381391401419714299100101102143104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140144
### First Application### Hello World
The _express.Server_ now inherits from _http.Server_, howeverfollows the same idiom by providing _express.createServer()_ as shown below:follows the same idiom by providing _express.createServer()_ as shown below. This meansthat you can utilize Express server's transparently with other libraries.
var app = require('express').createServer(); app.get('/', function(req, res){ res.send('hello world'); }); app.listen(3000);
### Configuration
Express supports arbitrary environments, such as _production_ and _development_. Developerscan use the _configure()_ method to setup needs required by the current environment. When_configure()_ is called without an environment name it will be run in _every_ environment prior to the environment specific callback.
In the example below we only _dumpExceptions_, and respond with exception stack tracesin _development_ mode, however for both environments we utilize _methodOverride_ and _bodyDecoder_.
app.configure(function(){ app.use('/', connect.methodOverride()); app.use('/', connect.bodyDecoder()); }); app.configure('development', function(){ app.use('/', connect.errorHandler({ dumpExceptions: true, showStack: true })); }); app.configure('production', function(){ app.use('/', connect.errorHandler()); });
For internal and arbitrary settings Express provides the _set(key[, val])_, _enable(key)_, _disable(key)_ methods:
app.configure(function(){ app.set('views', __dirname + '/views'); app.set('views'); // => "... views directory ..." app.enable('some feature'); // same as app.set('some feature', true); app.disable('some feature'); // same as app.set('some feature', false); });
### Settings
Express supports the following settings out of the box:
* _views_ Root views directory defaulting to **CWD/views** * _view engine_ Default view engine name for views rendered without extensions
### Routing
Express 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 _/user/12_, this74 unmodified lines connect.redirect(), connect.bodyDecoder() );
### Configuration
Express supports arbitrary environments, such as _production_ and _development_. Developerscan use the _configure()_ method to setup needs required by the current environment. When_configure()_ is called without an environment name it will be run in _every_ environment prior to the environment specific callback.
In the example below we only _dumpExceptions_, and respond with exception stack tracesin _development_ mode, however for both environments we utilize _methodOverride_ and _bodyDecoder_.
app.configure(function(){ app.use('/', connect.methodOverride()); app.use('/', connect.bodyDecoder()); }); app.configure('development', function(){ app.use('/', connect.errorHandler({ dumpExceptions: true, showStack: true })); }); app.configure('production', function(){ app.use('/', connect.errorHandler()); });
For internal and arbitrary settings Express provides the _set(key[, val])_, _enable(key)_, _disable(key)_ methods:
app.configure(function(){ app.set('views', __dirname + '/views'); app.set('views'); // => "... views directory ..." app.enable('some feature'); // same as app.set('some feature', true); app.disable('some feature'); // same as app.set('some feature', false); });
### Settings
Express supports the following settings out of the box:
* _views_ Root views directory defaulting to **CWD/views** * _view engine_ Default view engine name for views rendered without extensions
No newline at end of fileNo newline at end of file