Skip to content
Myr

migrate.html

This file

Path

docs/migrate.html

398 lines · 10.8 KiB · HTML

Last changed by

More view docsTj Holowaychukbefore adoption1c8ff48

History of this file

Take it

The walk stopped after 200 commits: lines older than 29641ae point at it.

Started new docsTj Holowaychukbefore adoption29641ae

lines 1–5why, one step back
1<html>
2 <head>3 <title>Express - node web framework</title>4 <style>5 #header {

Absolute labs bannerTj Holowaychukbefore adoption2b2fa7e

line 6why, one step back
6 position: absolute;

More docsTj Holowaychukbefore adoption900c5ed

line 7why, one step back
7 top: 10px;

More doc stylingTj Holowaychukbefore adoption87b7524

line 8why, one step back
8 left: 0;

Fixed bannerTj Holowaychukbefore adoption2fda5c7

lines 9–10why, one step back
9 padding: 12px 0;
10 text-indent: 40px;

More doc stylingTj Holowaychukbefore adoption87b7524

line 11why, one step back
11 width: 100%;

More docsTj Holowaychukbefore adoption900c5ed

lines 12–13why, one step back
12 border-top: 1px solid rgba(0,0,0,0.7);
13 border-bottom: 1px solid rgba(0,0,0,0.7);

More doc stylingTj Holowaychukbefore adoption87b7524

line 14why, one step back
14 background: rgba(255,255,255,0.1) url(http://www.sencha.com/favicon.ico) no-repeat 15px 50%;

Started new docsTj Holowaychukbefore adoption29641ae

line 15why, one step back
15 text-align: left;

More doc stylingTj Holowaychukbefore adoption87b7524

line 16why, one step back
16 color: #fff;

Started new docsTj Holowaychukbefore adoption29641ae

line 17why, one step back
17 }

More stylingTj Holowaychukbefore adoption7c651e6

lines 18–21why, one step back
18 #tagline {
19 margin-left: 75px;20 margin-bottom: 30px;21 color: rgba(255,255,255,0.7); }

More doc stylingTj Holowaychukbefore adoption87b7524

lines 22–46why, one step back
22 html {
23 background: #1c1c1c url(images/bg.tile.jpg); }2425 body {26 margin: 0;27 padding-bottom: 30px;28 font: 14px/1.4 "Helvetica Neue", "Lucida Grande", "Arial";29 font-size: 14px;30 line-height: 1.5;31 -webkit-text-stroke: 1px rgba(0, 0, 0, 0.1);32 -moz-text-stroke: 1px rgba(0, 0, 0, 0.1);33 background: url(images/bg.jpg) 50% 0 no-repeat;34 color: #8b8b8b; }3536 * {37 outline: none; }3839 em {40 color: white; }4142 a img {43 border: none !important; }4445 a {46 font-weight: bold;

Merge branch 'docs' into connectTj Holowaychukbefore adoption492f70f

line 47why, one step back
47 text-decoration: none;

More doc stylingTj Holowaychukbefore adoption87b7524

lines 48–55why, one step back
48 color: white;
49 -webkit-transition-property: opacity, -webkit-transform, color, background-color, padding, -webkit-box-shadow;50 -webkit-transition-duration: 0.15s;51 -webkit-transition-timing-function: ease-out; }52 a:hover {53 opacity: 0.8; }5455 h1, h2, h3 {

Added contributors back to docsTj Holowaychukbefore adoption195c8a9

line 56why, one step back
56 margin: 45px 0 0 0;

More doc stylingTj Holowaychukbefore adoption87b7524

lines 57–62why, one step back
57 color: white;
58 text-shadow: 1px 2px 2px rgba(0,0,0,0.6); }5960 h3 {61 font-size: 18px; }62

Started new docsTj Holowaychukbefore adoption29641ae

line 63why, one step back
63 pre {

More doc stylingTj Holowaychukbefore adoption87b7524

line 64why, one step back
64 margin: 20px 10px;

More stylingTj Holowaychukbefore adoption7c651e6

line 65why, one step back
65 padding: 25px 20px;

More doc stylingTj Holowaychukbefore adoption87b7524

lines 66–100why, one step back
66 background: rgba(0,0,0,0.5);
67 border: 1px solid #323232;68 -webkit-box-shadow: 1px 2px 2px rgba(0,0,0,0.6);69 -moz-box-shadow: 1px 2px 2px rgba(0,0,0,0.6);70 -webkit-border-radius: 5px;71 -moz-border-radius: 5px; }7273 code {74 font-family: "Helvetica Neue", "Lucida Grande", "Arial"; }7576 ul {77 margin: 15px 0;78 padding: 0 0 0 35px; }79 ul li {80 margin: 0;81 padding: 2px 0;82 list-style: square; }8384 .sect {85 margin-left: 40px; }8687 #logo {88 display: block;89 margin-left: 30%;90 margin-bottom: 30px;91 width: 194px;92 height: 51px;93 background: url(images/logo.png) 0 0 no-repeat;94 text-indent: -99999px; }95 #logo:hover {96 opacity: 0.7; }97 #logo:active {98 opacity: 0.3; }99100 #ribbon {

Added contributors back to docsTj Holowaychukbefore adoption195c8a9

line 101why, one step back
101 position: fixed;

More doc stylingTj Holowaychukbefore adoption87b7524

lines 102–112why, one step back
102 top: 0;
103 right: 0;104 z-index: 2; }105106 #wrapper {107 width: 100%;108 min-height: 800px;109 background: url(images/top.png) 0 0 repeat-x; }110111 #container {112 margin: 0 auto;

More stylingTj Holowaychukbefore adoption7c651e6

line 113why, one step back
113 padding-top: 110px;

More doc stylingTj Holowaychukbefore adoption87b7524

lines 114–115why, one step back
114 width: 550px; }
115

Merge branch 'docs' into connectTj Holowaychukbefore adoption492f70f

lines 116–126why, one step back
116 #toc {
117 position: fixed;118 top: 60px;119 left: 0;120 margin: 0 0 0 15px;121 padding: 15px;122 height: 100%;123 background: rgba(0,0,0,0.2);124 border-right: 1px solid rgba(255,255,255,0.05);125 }126 #toc li {

More view docsTj Holowaychukbefore adoption1c8ff48

line 127why, one step back
127 padding: 0;

Merge branch 'docs' into connectTj Holowaychukbefore adoption492f70f

lines 128–132why, one step back
128 list-style: none;
129 }130 #toc li a {131 font-size: 11px;132 }

More doc stylingTj Holowaychukbefore adoption87b7524

line 133why, one step back
133 #menu {

Added contrib docsTj Holowaychukbefore adoptionf0ba57b

line 134why, one step back
134 margin-left: 65px;

More doc stylingTj Holowaychukbefore adoption87b7524

lines 135–149why, one step back
135 padding: 0;
136 padding-bottom: 30px; }137 #menu li {138 display: inline;139 list-style: none; }140 #menu li a {141 display: block;142 float: left;143 margin: 0 2px;144 padding: 3px 15px;145 background: rgba(0,0,0,0.2);146 -webkit-border-radius: 8px;147 -moz-border-radius: 8px;148 -webkit-box-shadow: 1px 2px 2px rgba(0,0,0,0.6);149 -moz-box-shadow: 1px 2px 2px rgba(0,0,0,0.6);

Removed annoying padding transitionTj Holowaychukbefore adoption346b2a2

line 150why, one step back
150 -webkit-transition-property: opacity, -webkit-transform, color, background-color, -webkit-box-shadow;

More doc stylingTj Holowaychukbefore adoption87b7524

lines 151–159why, one step back
151 -webkit-transition-duration: 0.15s;
152 -webkit-transition-timing-function: ease-out; }153 #menu li a:hover,154 #menu li a.active {155 background: rgba(0,0,0,0.5); }156 #menu li a:active {157 background: rgba(0,0,0,0.1);158 -webkit-box-shadow: 1px 1px 1px rgba(0,0,0,0.4);159 -moz-box-shadow: 1px 1px 1px rgba(0,0,0,0.4); }

Started new docsTj Holowaychukbefore adoption29641ae

lines 160–162why, one step back
160 </style>
161 </head>162 <body>

More doc stylingTj Holowaychukbefore adoption87b7524

lines 163–165why, one step back
163 <a href='http://github.com/visionmedia/express'>
164 <img alt='Fork me on GitHub' id='ribbon' src='http://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png' /> 165 </a>

Started new docsTj Holowaychukbefore adoption29641ae

line 166why, one step back
166 <div id="header"><strong>Sencha</strong> labs</div>

Added images back to docsTj Holowaychukbefore adoption860b899

lines 167–169why, one step back
167 <div id="wrapper">
168 <div id="container">169 <a href='http://github.com/visionmedia/express' id='logo'>Express</a>

Fixed bannerTj Holowaychukbefore adoption2fda5c7

lines 170–173why, one step back
170 <p id="tagline">
171 High performance, high class web development for172 <a href="http://nodejs.org">Node.js</a>173 </p>

Added menu to docsTj Holowaychukbefore adoptionac560be

lines 174–176why, one step back
174 <ul id="menu">
175 <li><a href="index.html">Home</a></li>176 <li><a href="guide.html">Guide</a></li>

Added contrib docsTj Holowaychukbefore adoptionf0ba57b

line 177why, one step back
177 <li><a href="contrib.html">Contributing</a></li>

Added menu to docsTj Holowaychukbefore adoptionac560be

lines 178–179why, one step back
178 <li><a href="migrate.html">1.x Migration</a></li>
179 </ul>

Added images back to docsTj Holowaychukbefore adoption860b899

line 180why, one step back
180<div class='mp'>

Started guideTj Holowaychukbefore adoption9e3a0c6

line 181why, one step back
181<h3 id="Built-On-Connect">Built On Connect</h3>

Started new docsTj Holowaychukbefore adoption29641ae

line 182why, one step back
182

Started migration docsTj Holowaychukbefore adoption9e68a5b

line 183why, one step back
183<p>Express 1.x is written to run on-top of the <a href="http://extjs.github.com/Connect">Connect</a> middlware

Started guideTj Holowaychukbefore adoption9e3a0c6

lines 184–186why, one step back
184framework, thus the <em>Plugin</em> has been replaced by Connect's middleware. By abstracting our middleware
185to Connect we allow additional community frameworks to develop robust, high-level frameworks using186the same technologies as Express.</p>

Started migration docsTj Holowaychukbefore adoption9e68a5b

lines 187–205why, one step back
187
188<h3 id="Creating-Applications">Creating Applications</h3>189190<p>Previously due to legacy code implemented in the early days of node,191Express unfortunately had some globals. The DSL would previously be192accessed as shown below:</p>193194<pre><code>require('express');195196configure(function(){197 // app configuration198});199200get('/', function(){201 return 'hello world';202});203</code></pre>204205<p>Now we utilize the CommonJS module system appropriately, and

Removed backticks from docsTj Holowaychukbefore adoptionc3f71b3

lines 206–207why, one step back
206introduce <em>express.createServer()</em> which accepts the same arguments
207as <em>http.createServer()</em>:</p>

Started migration docsTj Holowaychukbefore adoption9e68a5b

lines 208–220why, one step back
208
209<pre><code>var express = require('express'),210 app = express.createServer();211212app.configure(function(){213 // app configuration214});215216app.get('/', function(req, res){217 res.send('hello world');218});219</code></pre>220

Docs for plugins vs middlewareTj Holowaychukbefore adoption927aae7

lines 221–233why, one step back
221<p>Express 1.x does <em>not</em> currently allow returning of a string.</p>
222223<h3 id="Plugins-vs-Middleware">Plugins vs Middleware</h3>224225<p>Previously Express was bundled with plugins, which were essentially what226are now Connect middleware. Previously plugins would be utilized in a manor227similar to below:</p>228229<pre><code>use(Logger);230use(MethodOverride);231use(Cookie);232</code></pre>233

Removed backticks from docsTj Holowaychukbefore adoptionc3f71b3

line 234why, one step back
234<p>Which we can now <em>use()</em> within our app, or pass to the <em>express.createServer()</em> method:</p>

Docs for plugins vs middlewareTj Holowaychukbefore adoption927aae7

lines 235–251why, one step back
235
236<pre><code>var connect = require('connect');237238var app = express.createServer(239 connect.logger(),240 connect.methodOverride(),241 connect.cookie()242);243</code></pre>244245<p>or:</p>246247<pre><code>var connect = require('connect');248var app = express.createServer();249250app.use('/', connect.logger());251app.use('/', connect.methodOverride());

Added configuration sectionTj Holowaychukbefore adoption83d2555

line 252why, one step back
252app.use('/', connect.cookieDecoder());

Docs for plugins vs middlewareTj Holowaychukbefore adoption927aae7

lines 253–255why, one step back
253</code></pre>
254255<p>For documentation on creating Connect middleware visit <a href="http://extjs.github.com/Connect/#Middleware-Authoring">Middleware Authoring</a>.</p>

Added view rendering migration sectionTj Holowaychukbefore adoption0b86ce2

line 256why, one step back
256

Started migration docsTj Holowaychukbefore adoption9e68a5b

lines 257–258why, one step back
257<h3 id="Running-Applications">Running Applications</h3>
258

Removed backticks from docsTj Holowaychukbefore adoptionc3f71b3

line 259why, one step back
259<p>Previously a global function <em>run()</em>, was available:</p>

Started migration docsTj Holowaychukbefore adoption9e68a5b

lines 260–263why, one step back
260
261<pre><code>run();262</code></pre>263

Removed backticks from docsTj Holowaychukbefore adoptionc3f71b3

line 264why, one step back
264<p>The new <em>express.Server</em> has the same API as <em>http.Server</em>,

Started migration docsTj Holowaychukbefore adoption9e68a5b

lines 265–269why, one step back
265so we can do things like:</p>
266267<pre><code>app.listen();268app.listen(3000);269</code></pre>

Started new docsTj Holowaychukbefore adoption29641ae

line 270why, one step back
270

Migration docs for paramsTj Holowaychukbefore adoptionda84c0b

lines 271–272why, one step back
271<h3 id="Route-Parameters">Route Parameters</h3>
272

Removed backticks from docsTj Holowaychukbefore adoptionc3f71b3

line 273why, one step back
273<p>Previously we could use <em>this.param()</em> to attempt

Migration docs for paramsTj Holowaychukbefore adoptionda84c0b

lines 274–280why, one step back
274fetching a route, query string, or request body parameter:</p>
275276<pre><code>get('/user/:id', function(){277 this.param('id');278});279</code></pre>280

Migration docs for req.param()Tj Holowaychukbefore adoptiondc77894

lines 281–288why, one step back
281<p>Polymorphic parameter access can be done using <code>req.param()</code>:</p>
282283<pre><code>app.get('/user/:id', function(){284 req.param('id');285});286</code></pre>287288<p>Route parameters are also passed as the third argument:</p>

Migration docs for paramsTj Holowaychukbefore adoptionda84c0b

lines 289–294why, one step back
289
290<pre><code>app.get('/user/:id', function(req, res, params){291 params.id;292});293</code></pre>294

Control passing docsTj Holowaychukbefore adoption548a070

lines 295–305why, one step back
295<h3 id="Passing-Route-Control">Passing Route Control</h3>
296297<p>Old express had a weak notion of route passing,298which did not support async, and was never properly299implemented for practical use:</p>300301<pre><code>get('/', function(){302 this.pass('/foobar');303});304</code></pre>305

Removed backticks from docsTj Holowaychukbefore adoptionc3f71b3

lines 306–307why, one step back
306<p>Now Express has access to Connect's <em>next()</em> function,
307which is passed as the fourth and final argument. Calling <em>next()</em> will

Control passing docsTj Holowaychukbefore adoption548a070

lines 308–316why, one step back
308pass control to the next <em>matching route</em>, or continue down the stack
309of Connect middleware.</p>310311<pre><code>app.get('/user/:id?', function(req, res, params, next){312 next();313});314315app.get('/user', function(){316 // ... respond

Added view rendering migration sectionTj Holowaychukbefore adoption0b86ce2

lines 317–322why, one step back
317});
318</code></pre>319320<h3 id="View-Rendering">View Rendering</h3>321322<p>View filenames no longer take the form <em>Express</em>.<em>TYPE</em>.<em>ENGINE</em>,

Removed backticks from docsTj Holowaychukbefore adoptionc3f71b3

lines 323–324why, one step back
323the <em>Content-Type</em> can be set via <em>res.contentType()</em> or
324<em>res.header()</em>. For example what was previously <em>layout.html.haml</em>,

Added view rendering migration sectionTj Holowaychukbefore adoption0b86ce2

lines 325–335why, one step back
325should now be <em>layout.haml</em>.</p>
326327<p>Previously a view render looked something like this:</p>328329<pre><code>get('/', function(){330 this.render('index.html.haml', {331 locals: { title: 'My Site' }332 });333});334</code></pre>335

Removed backticks from docsTj Holowaychukbefore adoptionc3f71b3

line 336why, one step back
336<p>We now have <em>res.render()</em>, however the options passed to <a href="http://github.com/visionmedia/haml.js">haml</a>, <a href="http://github.com/visionmedia/jade">jade</a>, and others

Added view rendering migration sectionTj Holowaychukbefore adoption0b86ce2

lines 337–342why, one step back
337remain the same.</p>
338339<pre><code>app.get('/', function(req, res){340 res.render('index.haml', {341 locals: { title: 'My Site' }342 });

Control passing docsTj Holowaychukbefore adoption548a070

lines 343–345why, one step back
343});
344</code></pre>345

Removed backticks from docsTj Holowaychukbefore adoptionc3f71b3

line 346why, one step back
346<p>Previously rendering of a collection via <em>partial()</em> would look something like this:</p>

Added partial migration docsTj Holowaychukbefore adoption2a674f4

lines 347–351why, one step back
347
348<pre><code>this.partial('comment.html.haml', { collection: comments });349</code></pre>350351<p>Although this worked just fine, it was generally to verbose, the similar but new API

Removed backticks from docsTj Holowaychukbefore adoptionc3f71b3

line 352why, one step back
352looks like this, as <em>partial()</em> is <em>always</em> passed as a local variable:</p>

Added partial migration docsTj Holowaychukbefore adoption2a674f4

lines 353–356why, one step back
353
354<pre><code>partial('comment.haml', { collection: comments });355</code></pre>356

Added more view docsTj Holowaychukbefore adoption2f96506

line 357why, one step back
357<p>To make things even less verbose we can assume the extension when omitted:</p>

Added partial migration docsTj Holowaychukbefore adoption2a674f4

lines 358–367why, one step back
358
359<pre><code>partial('comment', { collection: comments });360</code></pre>361362<p>And once again even further, when rendering a collection we can simply pass363an array, if no other options are desired:</p>364365<pre><code>partial('comments', comments);366</code></pre>367

Merge branch 'redirect' into connectTj Holowaychukbefore adoption87cfca7

line 368why, one step back
368<h3 id="Redirecting">Redirecting</h3>

Added redirect migration docsTj Holowaychukbefore adoption74432a6

lines 369–374why, one step back
369
370<p>Previously you would</p>371372<pre><code>this.redirect('/somewhere');373</code></pre>374

Merge branch 'redirect' into connectTj Holowaychukbefore adoption87cfca7

line 375why, one step back
375<p>However you would now:</p>

Added redirect migration docsTj Holowaychukbefore adoption74432a6

lines 376–377why, one step back
376
377<pre><code>res.redirect('/somewhere');

Merge branch 'redirect' into connectTj Holowaychukbefore adoption87cfca7

line 378why, one step back
378res.redirect('/somewhere', 301);

Added contrib docsTj Holowaychukbefore adoptionf0ba57b

lines 379–391why, one step back
379</code></pre>
380381<h3 id="HTTP-Client">HTTP Client</h3>382383<p>Previously Express provided a high level http client, this library is no more384as it does not belong in Express, however it may be resurrected as a separate module.</p>385386<h3 id="Core-Extensions">Core Extensions</h3>387388<p>Express is no longer dependent on the <a href="http://github.com/visionmedia/ext.js">JavaScript Extensions</a> library, so those of you using the methods provided by it such as <code>Object.merge(a, b)</code> will need to389roll your own, or install the module via:</p>390391<pre><code>$ npm install ext

Added redirect migration docsTj Holowaychukbefore adoption74432a6

lines 392–393why, one step back
392</code></pre>
393

Started new docsTj Holowaychukbefore adoption29641ae

line 394why, one step back
394</div>

Added images back to docsTj Holowaychukbefore adoption860b899

line 395why, one step back
395 </div>

Started new docsTj Holowaychukbefore adoption29641ae

lines 396–398why, one step back
396 </div>
397 </body>398</html>