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
Provenance
- Commit
927aae7- Tree
fbe6e96- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
2a674f4
3 files changed+123 added−3 removed
modified:docs/migrate.1+56 added-1 removed
48 unmodified lines49 .50 .IP "" 051 .52 .P53-Express 1\.x does \fInot\fR allow returning of a string\.53+Express 1\.x does \fInot\fR currently allow returning of a string\.54 .55+.SS "Plugins vs Middleware"56+Previously 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+.nf61+62+use(Logger);63+use(MethodOverride);64+use(Cookie);65+.66+.fi67+.68+.IP "" 069+.70+.P71+Which we can now \fBuse()\fR within our app, or pass to the \fBexpress\.createServer()\fR method:72+.73+.IP "" 474+.75+.nf76+77+var connect = require(\'connect\');78+79+var app = express\.createServer(80+ connect\.logger(),81+ connect\.methodOverride(),82+ connect\.cookie()83+);84+.85+.fi86+.87+.IP "" 088+.89+.P90+or:91+.92+.IP "" 493+.94+.nf95+96+var connect = require(\'connect\');97+var app = express\.createServer();98+99+app\.use(\'/\', connect\.logger());100+app\.use(\'/\', connect\.methodOverride());101+app\.use(\'/\', connect\.cookie());102+.103+.fi104+.105+.IP "" 0106+.107+.P108+For documentation on creating Connect middleware visit Middleware Authoring \fIhttp://extjs\.github\.com/Connect/#Middleware\-Authoring\fR\.109+.110 .SS "Running Applications"111 Previously a global function \fBrun()\fR, was available:112 .113 .IP "" 4176 unmodified linesmodified:docs/migrate.html+35 added-1 removed
187 unmodified lines188 res.send('hello world');189 });190 </code></pre>191 192-<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>193 194+<h3 id="Plugins-vs-Middleware">Plugins vs Middleware</h3>195+196+<p>Previously Express was bundled with plugins, which were essentially what197+are now Connect middleware. Previously plugins would be utilized in a manor198+similar to below:</p>199+200+<pre><code>use(Logger);201+use(MethodOverride);202+use(Cookie);203+</code></pre>204+205+<p>Which we can now <code>use()</code> within our app, or pass to the <code>express.createServer()</code> method:</p>206+207+<pre><code>var connect = require('connect');208+209+var app = express.createServer(210+ connect.logger(),211+ connect.methodOverride(),212+ connect.cookie()213+);214+</code></pre>215+216+<p>or:</p>217+218+<pre><code>var connect = require('connect');219+var app = express.createServer();220+221+app.use('/', connect.logger());222+app.use('/', connect.methodOverride());223+app.use('/', connect.cookie());224+</code></pre>225+226+<p>For documentation on creating Connect middleware visit <a href="http://extjs.github.com/Connect/#Middleware-Authoring">Middleware Authoring</a>.</p>227+228 <h3 id="Running-Applications">Running Applications</h3>229 230 <p>Previously a global function <code>run()</code>, was available:</p>231 105 unmodified linesmodified:docs/migrate.md+32 added-1 removed
33 unmodified lines34353637383839404142434445464748495051525354555657585960616263646566676869707172737487 unmodified lines33 unmodified lines app.get('/', function(req, res){ res.send('hello world'); });
Express 1.x does _not_ allow returning of a string.Express 1.x does _not_ currently allow returning of a string.
### Plugins vs Middleware
Previously Express was bundled with plugins, which were essentially whatare now Connect middleware. Previously plugins would be utilized in a manorsimilar to below:
use(Logger); use(MethodOverride); use(Cookie);
Which we can now `use()` within our app, or pass to the `express.createServer()` method:
var connect = require('connect');
var app = express.createServer( connect.logger(), connect.methodOverride(), connect.cookie() );
or:
var connect = require('connect'); var app = express.createServer();
app.use('/', connect.logger()); app.use('/', connect.methodOverride()); app.use('/', connect.cookie());
For documentation on creating Connect middleware visit [Middleware Authoring](http://extjs.github.com/Connect/#Middleware-Authoring).
### Running Applications
Previously a global function `run()`, was available:
87 unmodified lines