Skip to content
Myr

Started guide

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 2fda5c7 · Browse files · 7 files+396 added−6 removed
This commit

State

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

Diff stats

7 files+396 added−6 removed

  • other:+396 added−6 removed

7 files+396 added−6 removed

added:docs/guide.1+100 added
1.\" generated with Ronn/v0.6.62.\" http://github.com/rtomayko/ronn/3.4.TH "GUIDE" "" "July 2010" "" ""5.6.SS "Routing"7Express 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\.8.9.IP "" 410.11.nf1213app\.get(\'/user/:id\', function(req, res, params){14 res\.send(\'user \' + params\.id);15});16.17.fi18.19.IP "" 020.21.P22Alternatively we may want to create, or \fBPOST\fR a user:23.24.IP "" 425.26.nf2728app\.post(\'/user\', function(){29 // \.\.\. logic30});31.32.fi33.34.IP "" 035.36.P37A route is simple a string which is compiled to a \fIRegExp\fR internally\. For example when \fI/user/:id\fR is compiled, a simplified version of the regexp may look similar to:38.39.IP "" 440.41.nf4243\\/user\\/([^\\/]+)\\/?44.45.fi46.47.IP "" 048.49.P50Literal regular expressions may also be passed for complex uses:51.52.IP "" 453.54.nf5556app\.get(/^\\/foo(bar)?$/, function(){});57.58.fi59.60.IP "" 061.62.P63Below are some route examples, and the associated paths that they may consume:64.65.IP "" 466.67.nf6869 \"/user/:id\"70 /user/127172 \"/users/:id?\"73 /users/574 /users7576 \"/files/*\"77 /files/jquery\.js78 /files/javascripts/jquery\.js7980 \"/file/*\.*\"81 /files/jquery\.js82 /files/javascripts/jquery\.js8384 \"/user/:id/:operation?\"85 /user/186 /user/1/edit8788 \"/products\.:format\"89 /products\.json90 /products\.xml9192 \"/products\.:format?\"93 /products\.json94 /products\.xml95 /products96.97.fi98.99.IP "" 0100
added:docs/guide.html+229 added
1<html>2 <head>3 <title>Express - node web framework</title>4 <style>5 #header {6 position: absolute;7 top: 10px;8 left: 0;9 padding: 12px 0;10 text-indent: 40px;11 width: 100%;12 border-top: 1px solid rgba(0,0,0,0.7);13 border-bottom: 1px solid rgba(0,0,0,0.7);14 background: rgba(255,255,255,0.1) url(http://www.sencha.com/favicon.ico) no-repeat 15px 50%;15 text-align: left;16 color: #fff;17 }18 #tagline {19 margin-left: 75px;20 margin-bottom: 30px;21 color: rgba(255,255,255,0.7); }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;47 color: white;48 -webkit-transition-property: opacity, -webkit-transform, color, background-color, padding, -webkit-box-shadow;49 -webkit-transition-duration: 0.15s;50 -webkit-transition-timing-function: ease-out; }51 a:hover {52 opacity: 0.8; }5354 h1, h2, h3 {55 margin: 45px 0 0 0;56 color: white;57 text-shadow: 1px 2px 2px rgba(0,0,0,0.6); }5859 h3 {60 margin-left: 20px;61 font-size: 18px; }6263 pre {64 margin: 20px 10px;65 padding: 25px 20px;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 {101 position: fixed;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;113 padding-top: 110px;114 width: 550px; }115116 #menu {117 margin-left: 130px;118 padding: 0;119 padding-bottom: 30px; }120 #menu li {121 display: inline;122 list-style: none; }123 #menu li a {124 display: block;125 float: left;126 margin: 0 2px;127 padding: 3px 15px;128 background: rgba(0,0,0,0.2);129 -webkit-border-radius: 8px;130 -moz-border-radius: 8px;131 -webkit-box-shadow: 1px 2px 2px rgba(0,0,0,0.6);132 -moz-box-shadow: 1px 2px 2px rgba(0,0,0,0.6);133 -webkit-transition-property: opacity, -webkit-transform, color, background-color, padding, -webkit-box-shadow;134 -webkit-transition-duration: 0.15s;135 -webkit-transition-timing-function: ease-out; }136 #menu li a:hover,137 #menu li a.active {138 padding: 3px 20px;139 background: rgba(0,0,0,0.5); }140 #menu li a:active {141 background: rgba(0,0,0,0.1);142 -webkit-box-shadow: 1px 1px 1px rgba(0,0,0,0.4);143 -moz-box-shadow: 1px 1px 1px rgba(0,0,0,0.4); }144 </style>145 </head>146 <body>147 <a href='http://github.com/visionmedia/express'> 148 <img alt='Fork me on GitHub' id='ribbon' src='http://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png' /> 149 </a>150 <div id="header"><strong>Sencha</strong> labs</div>151 <div id="wrapper">152 <div id="container">153 <a href='http://github.com/visionmedia/express' id='logo'>Express</a> 154 <p id="tagline">155 High performance, high class web development for156 <a href="http://nodejs.org">Node.js</a>157 </p>158 <ul id="menu">159 <li><a href="index.html">Home</a></li>160 <li><a href="guide.html">Guide</a></li>161 <li><a href="migrate.html">1.x Migration</a></li>162 </ul>163<div class='mp'>164<h3 id="Routing">Routing</h3>165166<p>Express utilizes the HTTP verbs to provide a meaningful, expressive routing API.167For example we may want to render a user's account for the path <em>/user/12</em>, this168can be done by defining the route below.</p>169170<pre><code>app.get('/user/:id', function(req, res, params){171 res.send('user ' + params.id);172});173</code></pre>174175<p>Alternatively we may want to create, or <strong>POST</strong> a user:</p>176177<pre><code>app.post('/user', function(){178 // ... logic179});180</code></pre>181182<p>A route is simple a string which is compiled to a <em>RegExp</em> internally. For example183when <em>/user/:id</em> is compiled, a simplified version of the regexp may look similar to:</p>184185<pre><code>\/user\/([^\/]+)\/?186</code></pre>187188<p>Literal regular expressions may also be passed for complex uses:</p>189190<pre><code>app.get(/^\/foo(bar)?$/, function(){});191</code></pre>192193<p>Below are some route examples, and the associated paths that they194may consume:</p>195196<pre><code> "/user/:id"197 /user/12198199 "/users/:id?"200 /users/5201 /users202203 "/files/*"204 /files/jquery.js205 /files/javascripts/jquery.js206207 "/file/*.*"208 /files/jquery.js209 /files/javascripts/jquery.js210211 "/user/:id/:operation?"212 /user/1213 /user/1/edit214215 "/products.:format"216 /products.json217 /products.xml218219 "/products.:format?"220 /products.json221 /products.xml222 /products223</code></pre>224225</div>226 </div>227 </div>228 </body>229</html>
added:docs/guide.md+56 added
modified:docs/migrate.1+2 added-2 removed
1 unmodified line
2.\" http://github.com/rtomayko/ronn/3.4.TH "MIGRATE" "" "July 2010" "" ""5.6.SH "Migration Guide"7Express 1\.x is written to run on\-top of the Connect \fIhttp://extjs\.github\.com/Connect\fR middlware framework, thus the \fIPlugin\fR has been replaced by Connect\'s middleware\.6.SS "Built On Connect"7Express 1\.x is written to run on\-top of the Connect \fIhttp://extjs\.github\.com/Connect\fR middlware framework, thus the \fIPlugin\fR has been replaced by Connect\'s middleware\. By abstracting our middleware to Connect we allow additional community frameworks to develop robust, high\-level frameworks using the same technologies as Express\.8.9.SS "Creating Applications"10Previously due to legacy code implemented in the early days of node, Express unfortunately had some globals\. The DSL would previously be accessed as shown below:11.
319 unmodified lines
modified:docs/migrate.html+4 added-2 removed
159 unmodified lines
160 <li><a href="guide.html">Guide</a></li>161 <li><a href="migrate.html">1.x Migration</a></li>162 </ul>163<div class='mp'>164<h2 id="Migration-Guide">Migration Guide</h2>164<h3 id="Built-On-Connect">Built On Connect</h3>165166<p>Express 1.x is written to run on-top of the <a href="http://extjs.github.com/Connect">Connect</a> middlware167framework, thus the <em>Plugin</em> has been replaced by Connect's middleware.</p>167framework, thus the <em>Plugin</em> has been replaced by Connect's middleware. By abstracting our middleware168to Connect we allow additional community frameworks to develop robust, high-level frameworks using169the same technologies as Express.</p>170171<h3 id="Creating-Applications">Creating Applications</h3>172173<p>Previously due to legacy code implemented in the early days of node,
194 unmodified lines
modified:docs/migrate.md+4 added-2 removed
12## Migration Guide2### Built On Connect34Express 1.x is written to run on-top of the [Connect](http://extjs.github.com/Connect) middlware5framework, thus the _Plugin_ has been replaced by Connect's middleware.5framework, thus the _Plugin_ has been replaced by Connect's middleware. By abstracting our middleware6to Connect we allow additional community frameworks to develop robust, high-level frameworks using7the same technologies as Express.89### Creating Applications1011Previously due to legacy code implemented in the early days of node,
168 unmodified lines
modified:Makefile+1 added
2 unmodified lines
3LIB_PREFIX = ~/.node_libraries45DOCS = docs/index.md \6 docs/executable.md \7 docs/guide.md \8 docs/migrate.md910MANPAGES =$(DOCS:.md=.1)11HTMLDOCS =$(DOCS:.md=.html)
58 unmodified lines