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 4c95031 · Browse files · 6 files·+26 added−30 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+26 added−30 removed
- other:+26 added−30 removed
Provenance
- Commit
50006f7- Tree
38ce7ce- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
4c95031
6 files changed+26 added−30 removed
modified:docs/guide.1+7 added-11 removed
1 .\" generated with Ronn/v0.7.32 .\" http://github.com/rtomayko/ronn/tree/0.7.33 .4-.TH "GUIDE" "" "December 2010" "" ""4+.TH "GUIDE" "" "March 2011" "" ""5 .6 .SH "NAME"7 \fBguide\fR8 .32 unmodified lines41 42 var app = require(\'express\')\.createServer();43 44 app\.get(\'/\', function(req, res){45- res\.send(\'hello world\');45+ res\.send(\'hello world\');46 });47 48 app\.listen(3000);49 .14 unmodified lines64 app\.configure(function(){65 app\.use(express\.methodOverride());66 app\.use(express\.bodyDecoder());67 app\.use(app\.router);68- app\.use(express\.staticProvider(__dirname + \'/public\'));68 });69 70 app\.configure(\'development\', function(){71+ app\.use(express\.staticProvider(__dirname + \'/public\'));72 app\.use(express\.errorHandler({ dumpExceptions: true, showStack: true }));73 });74 75 app\.configure(\'production\', function(){76+ var oneYear = 31557600000;77+ app\.use(express\.staticProvider({ root: __dirname + \'/public\', maxAge: oneYear }));78 app\.use(express\.errorHandler());79 });80 .81 .fi56 unmodified lines138 .139 .IP "\(bu" 4140 \fIview options\fR An object specifying global view options141 .140-.IP "\(bu" 4141-\fIstream threshold\fR Bytesize indicating when a file should be streamed for \fIres\.sendfile()\fR using \fIfs\.ReadStream()\fR and \fIsys\.pump()\fR\.142-.142 .IP "" 0143 .144 .SS "Routing"145 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 available as \fBreq\.params\fR\.1065 unmodified lines1211 .fi1212 .1213 .IP "" 01214 .1216-.SS "req\.param(name)"1217-Return the value of param \fIname\fR when present\.1215+.SS "req\.param(name[, default])"1216+Return the value of param \fIname\fR when present or \fIdefault\fR\.1217 .1218 .IP "\(bu" 41219 Checks route placeholders (\fIreq\.params\fR), ex: /user/:id1220 .139 unmodified lines1360 .fi1361 .1362 .IP "" 01363 .1365-.P1366-When the filesize exceeds the \fIstream threshold\fR (defaulting to 32k), the file will be streamed using \fIfs\.ReadStream\fR and \fIsys\.pump()\fR\.1367-.1364 .SS "res\.download(file[, filename])"1365 Transfer the given \fIfile\fR as an attachment with optional alternative \fIfilename\fR\.1366 .1367 .IP "" 4604 unmodified linesmodified:docs/guide.html+7 added-8 removed
197 unmodified lines198 <li><a href="#" class="toggle">+</a> <a class="section-title" href="#">Request</a><ul class="section" id="section-Request">199 <li><a href="#req-header-key-defaultValue-">header()</a></li>200 <li><a href="#req-accepts-type-">accepts()</a></li>201 <li><a href="#req-is-type-">is()</a></li>202-<li><a href="#req-param-name-">param()</a></li>202+<li><a href="#req-param-name-default-">param()</a></li>203 <li><a href="#req-flash-type-msg-">flash()</a></li>204 <li><a href="#req-isXMLHttpRequest">isXMLHttpRequest</a></li>205 </ul></li>206 <li><a href="#" class="toggle">+</a> <a class="section-title" href="#">Response</a><ul class="section" id="section-Response">60 unmodified lines267 268 <pre><code>var app = require('express').createServer();269 270 app.get('/', function(req, res){271- res.send('hello world');271+ res.send('hello world');272 });273 274 app.listen(3000);275 </code></pre>13 unmodified lines289 <pre><code>app.configure(function(){290 app.use(express.methodOverride());291 app.use(express.bodyDecoder());292 app.use(app.router);293- app.use(express.staticProvider(__dirname + '/public'));293 });294 295 app.configure('development', function(){296+ app.use(express.staticProvider(__dirname + '/public'));297 app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));298 });299 300 app.configure('production', function(){301+ var oneYear = 31557600000;302+ app.use(express.staticProvider({ root: __dirname + '/public', maxAge: oneYear }));303 app.use(express.errorHandler());304 });305 </code></pre>306 28 unmodified lines335 <li><em>home</em> Application base path used for <em>res.redirect()</em> and transparently handling mounted apps.</li>336 <li><em>views</em> Root views directory defaulting to <strong>CWD/views</strong></li>337 <li><em>view engine</em> Default view engine name for views rendered without extensions</li>338 <li><em>view options</em> An object specifying global view options</li>337-<li><em>stream threshold</em> Bytesize indicating when a file should be streamed for <em>res.sendfile()</em> using <em>fs.ReadStream()</em> and <em>sys.pump()</em>.</li>339 </ul>340 341 342 <h3 id="Routing">Routing</h3>661 unmodified lines1004 1005 <pre><code>req.is('*/json');1006 </code></pre>1007 1007-<h3 id="req-param-name-">req.param(name)</h3>1008+<h3 id="req-param-name-default-">req.param(name[, default])</h3>1009 1009-<p>Return the value of param <em>name</em> when present.</p>1010+<p>Return the value of param <em>name</em> when present or <em>default</em>.</p>1011 1012 <ul>1013 <li>Checks route placeholders (<em>req.params</em>), ex: /user/:id</li>1014 <li>Checks query string params (<em>req.query</em>), ex: ?id=12</li>85 unmodified lines1100 }1101 });1102 </code></pre>1103 1103-<p>When the filesize exceeds the <em>stream threshold</em> (defaulting to 32k), the file will be streamed using <em>fs.ReadStream</em> and <em>sys.pump()</em>.</p>1104-1104 <h3 id="res-download-file-filename-">res.download(file[, filename])</h3>1105 1106 <p>Transfer the given <em>file</em> as an attachment with optional alternative <em>filename</em>.</p>1107 380 unmodified linesmodified:docs/guide.md+6 added-6 removed
14 unmodified lines15 follows the same idiom by providing _express.createServer()_ as shown below. This means16 that you can utilize Express server's transparently with other libraries.17 18 var app = require('express').createServer();19- 20- app.get('/', function(req, res){21- res.send('hello world');22- });23- 24- app.listen(3000);19+ 20+ app.get('/', function(req, res){21+ res.send('hello world');22+ });23+ 24+ app.listen(3000);25 26 ### Configuration27 28 Express supports arbitrary environments, such as _production_ and _development_. Developers1080 unmodified linesmodified:docs/index.1+4 added-4 removed
1 .\" generated with Ronn/v0.7.32 .\" http://github.com/rtomayko/ronn/tree/0.7.33 .4-.TH "INDEX" "" "December 2010" "" ""4+.TH "INDEX" "" "March 2011" "" ""5 .6 .SH "NAME"7 \fBindex\fR8 .30 unmodified lines39 .IP "\(bu" 440 Content negotiation41 .42 .IP "\(bu" 443+Application mounting44+.45+.IP "\(bu" 446 Focus on high performance47 .48 .IP "\(bu" 449 View rendering and partials support40 unmodified lines90 .IP "\(bu" 491 Follow tjholowaychuk \fIhttp://twitter\.com/tjholowaychuk\fR on twitter for updates92 .93 .IP "\(bu" 491-Annotated source documentation \fIapi\.html\fR92-.93-.IP "\(bu" 494 View the Connect \fIhttp://github\.com/senchalabs/connect\fR repo for middleware usage95 .96 .IP "\(bu" 497 View the Connect Wiki \fIhttp://wiki\.github\.com/senchalabs/connect/\fR for contrib middleware12 unmodified linesmodified:docs/index.html+1 added-1 removed
210 unmodified lines211 <li>Redirection helpers</li>212 <li>Dynamic view helpers</li>213 <li>Application level view options</li>214 <li>Content negotiation</li>215+<li>Application mounting</li>216 <li>Focus on high performance</li>217 <li>View rendering and partials support</li>218 <li>Environment based configuration</li>219 <li>Session based flash notifications</li>19 unmodified lines239 240 <ul>241 <li><a href="http://groups.google.com/group/express-js">Google Group</a> for discussion</li>242 <li>Follow <a href="http://twitter.com/tjholowaychuk">tjholowaychuk</a> on twitter for updates</li>242-<li>Annotated source <a href="api.html">documentation</a></li>243 <li>View the <a href="http://github.com/senchalabs/connect">Connect</a> repo for middleware usage</li>244 <li>View the <a href="http://wiki.github.com/senchalabs/connect/">Connect Wiki</a> for contrib middleware</li>245 <li>View the <a href="http://github.com/visionmedia/express/tree/master/examples/">examples</a></li>246 <li>View the <a href="http://github.com/visionmedia/express">source</a></li>9 unmodified linesmodified:docs/index.md+1 added
12 unmodified lines13141516171819202122 unmodified lines12 unmodified lines * Redirection helpers * Dynamic view helpers * Application level view options * Content negotiation * Application mounting * Focus on high performance * View rendering and partials support * Environment based configuration * Session based flash notifications22 unmodified lines