Skip to content
Myr

generate 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 723774a · Browse files · 2 files+28 added−14 removed
This commit

State

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

Diff stats

2 files+28 added−14 removed

  • other:+28 added−14 removed

2 files+28 added−14 removed

modified:docs/contrib.html+2 added-3 removed
190 unmodified lines
191 <li><a href="applications.html">Applications</a></li>192 </ul>193<h3>Development Dependencies</h3>194195<p>Express development dependencies are stored within the <em>./support</em> directory. To196update them execute:</p>195<p>First install the dev dependencies by executing the following command in the repo&rsquo;s directory:</p>196198<pre><code>$ git submodule update --init197<pre><code>$ npm install198</code></pre>199200<h3>Running Tests</h3>201
38 unmodified lines
modified:docs/guide.html+26 added-11 removed
253 unmodified lines
254255<pre><code>$ npm install express256</code></pre>257258<p>or to access the <code>express(1)</code> executable install globally:</p>259260<pre><code>$ npm install -g express261</code></pre>262263<h2>Quick Start</h2>264265<p> The quickest way to get started with express is to utilize the executable <code>express(1)</code> to generate an application as shown below:</p>266267<p> Create the app:</p>268269<pre><code>$ npm install -g express270$ express /tmp/foo &amp;&amp; cd /tmp/foo271</code></pre>272273<p> Install dependencies:</p>274275<pre><code>$ npm install -d276</code></pre>277278<p> Start the server:</p>279280<pre><code>$ node app.js281</code></pre>282283<h3 id="creating-a server">Creating A Server</h3>284285<p> To create an instance of the <em>express.HTTPServer</em>, simply invoke the <em>createServer()</em> method. With our instance <em>app</em> we can then define routes based on the HTTP verbs, in this example <em>app.get()</em>.</p>286
242 unmodified lines
529</code></pre>530531<p>Alternatively we can <em>use()</em> them which is useful when adding middleware within <em>configure()</em> blocks, in a progressive manor.</p>532508<pre><code>app.use(express.logger({ format: ':method :uri' }));533<pre><code>app.use(express.logger({ format: ':method :url' }));534</code></pre>535536<p>Typically with connect middleware you would <em>require(&lsquo;connect&rsquo;)</em> like so:</p>537
258 unmodified lines
796 res.send('user ' + req.user.name);797});798</code></pre>799775<p>For simple cases such as route placeholder validation and coercion we can simple pass a callback which has an arity of 1 (accepts one argument). Any errors thrown will be passed to <em>next(err)</em>.</p>776777<pre><code>app.param('number', function(n){ return parseInt(n, 10); });778</code></pre>779780<p>We may also apply the same callback to several placeholders, for example a route GET <em>/commits/:from-:to</em> are both numbers, so we may define them as an array:</p>781782<pre><code>app.param(['from', 'to'], function(n){ return parseInt(n, 10); });783</code></pre>784800<h3 id="view-rendering">View Rendering</h3>801802<p>View filenames take the form &ldquo;&lt;name&gt;.&lt;engine&gt;&rdquo;, where &lt;engine&gt; is the name803of the module that will be required. For example the view <em>layout.ejs</em> will
988 unmodified lines