Skip to content
Myr

Docs for plugins vs middleware

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 2a674f4 · Browse files · 3 files+123 added−3 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+123 added−3 removed

  • other:+123 added−3 removed

3 files+123 added−3 removed

modified:docs/migrate.1+56 added-1 removed
48 unmodified lines
49.50.IP "" 051.52.P53Express 1\.x does \fInot\fR allow returning of a string\.53Express 1\.x does \fInot\fR currently allow returning of a string\.54.55.SS "Plugins vs Middleware"56Previously Express was bundled with plugins, which were essentially what are now Connect middleware\. Previously plugins would be utilized in a manor similar to below:57.58.IP "" 459.60.nf6162use(Logger);63use(MethodOverride);64use(Cookie);65.66.fi67.68.IP "" 069.70.P71Which we can now \fBuse()\fR within our app, or pass to the \fBexpress\.createServer()\fR method:72.73.IP "" 474.75.nf7677var connect = require(\'connect\');7879var app = express\.createServer(80 connect\.logger(),81 connect\.methodOverride(),82 connect\.cookie()83);84.85.fi86.87.IP "" 088.89.P90or:91.92.IP "" 493.94.nf9596var connect = require(\'connect\');97var app = express\.createServer();9899app\.use(\'/\', connect\.logger());100app\.use(\'/\', connect\.methodOverride());101app\.use(\'/\', connect\.cookie());102.103.fi104.105.IP "" 0106.107.P108For documentation on creating Connect middleware visit Middleware Authoring \fIhttp://extjs\.github\.com/Connect/#Middleware\-Authoring\fR\.109.110.SS "Running Applications"111Previously a global function \fBrun()\fR, was available:112.113.IP "" 4
176 unmodified lines
modified:docs/migrate.html+35 added-1 removed
187 unmodified lines
188 res.send('hello world');189});190</code></pre>191192<p>Express 1.x does <em>not</em> allow returning of a string.</p>192<p>Express 1.x does <em>not</em> currently allow returning of a string.</p>193194<h3 id="Plugins-vs-Middleware">Plugins vs Middleware</h3>195196<p>Previously Express was bundled with plugins, which were essentially what197are now Connect middleware. Previously plugins would be utilized in a manor198similar to below:</p>199200<pre><code>use(Logger);201use(MethodOverride);202use(Cookie);203</code></pre>204205<p>Which we can now <code>use()</code> within our app, or pass to the <code>express.createServer()</code> method:</p>206207<pre><code>var connect = require('connect');208209var app = express.createServer(210 connect.logger(),211 connect.methodOverride(),212 connect.cookie()213);214</code></pre>215216<p>or:</p>217218<pre><code>var connect = require('connect');219var app = express.createServer();220221app.use('/', connect.logger());222app.use('/', connect.methodOverride());223app.use('/', connect.cookie());224</code></pre>225226<p>For documentation on creating Connect middleware visit <a href="http://extjs.github.com/Connect/#Middleware-Authoring">Middleware Authoring</a>.</p>227228<h3 id="Running-Applications">Running Applications</h3>229230<p>Previously a global function <code>run()</code>, was available:</p>231
105 unmodified lines
modified:docs/migrate.md+32 added-1 removed