Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 121 lines (88 sloc) 3.269 kb
8675f12 TJ Holowaychuk New doc files
tj authored
1
fa08323 TJ Holowaychuk Markdown
tj authored
2 # Express
8675f12 TJ Holowaychuk New doc files
tj authored
3
4 Insanely fast (and small) server-side JavaScript web development framework
5 built on node.js and the V8 JavaScript engine.
6
7 * Stay tuned, coming soon :)
8
fa08323 TJ Holowaychuk Markdown
tj authored
9 ## Features (so far)
8675f12 TJ Holowaychuk New doc files
tj authored
10
11 * Sexy DSL
12 * Mime helpers
13 * Nested parameter parsing
14 * Full test coverage
15 * Test helpers (mock requests etc)
16 * Cookie support
17 * Session support
18 * Faux method support for RESTful apps
19 * Extendable using Express 'Modules'
20 * Static file serving
05ea7a5 TJ Holowaychuk Docs
tj authored
21 * View support
8675f12 TJ Holowaychuk New doc files
tj authored
22 * Routing
23 * string matching
24 * regexp with captures
25 * param key substitution
26 * pre-conditions
27 * overidding
28 * etc
cc5983f TJ Holowaychuk Performance docs
tj authored
29
fa08323 TJ Holowaychuk Markdown
tj authored
30 ## Performance
cc5983f TJ Holowaychuk Performance docs
tj authored
31
32 Extensive benchmarking will wait until a development version
33 has been released. However for simple an average route and response
34 body Ruby's Sinatra scored 1454 request per second using Thin, while
35 Express scored 2762.
8675f12 TJ Holowaychuk New doc files
tj authored
36
fa08323 TJ Holowaychuk Markdown
tj authored
37 ## Examples
8675f12 TJ Holowaychuk New doc files
tj authored
38
fa08323 TJ Holowaychuk Markdown
tj authored
39 // GET /user/tj/edit
8675f12 TJ Holowaychuk New doc files
tj authored
40
fa08323 TJ Holowaychuk Markdown
tj authored
41 get('user/:name/:operation', function(){
42 param('operation') + 'ing ' + param('name')
43 })
8675f12 TJ Holowaychuk New doc files
tj authored
44
fa08323 TJ Holowaychuk Markdown
tj authored
45 // GET /articles
8675f12 TJ Holowaychuk New doc files
tj authored
46
fa08323 TJ Holowaychuk Markdown
tj authored
47 get('articles', function(){
48 'list of articles'
49 })
8675f12 TJ Holowaychuk New doc files
tj authored
50
fa08323 TJ Holowaychuk Markdown
tj authored
51 // GET /articles/12
8675f12 TJ Holowaychuk New doc files
tj authored
52
fa08323 TJ Holowaychuk Markdown
tj authored
53 get(/articles\/(\d+)/, function(){
54 'article id ' + captures[1]
55 })
8675f12 TJ Holowaychuk New doc files
tj authored
56
fa08323 TJ Holowaychuk Markdown
tj authored
57 // POST /user/:id
8675f12 TJ Holowaychuk New doc files
tj authored
58
fa08323 TJ Holowaychuk Markdown
tj authored
59 post('user/:id', function(){
60 User.destroy(params('id')) ?
61 'User deleted' :
62 'Failed to delete user'
63 })
8675f12 TJ Holowaychuk New doc files
tj authored
64
fa08323 TJ Holowaychuk Markdown
tj authored
65 // GET /login
7807f42 TJ Holowaychuk Added POST urlencoded body parsing
tj authored
66
fa08323 TJ Holowaychuk Markdown
tj authored
67 get('login', function() {
68 '<form method="post" action="/login"> \
69 <input type="text" name="user[name]" /> \
70 <input type="password" name="user[pass]" /> \
71 <input type="submit" value="Login"/> \
72 </form>'
73 })
7807f42 TJ Holowaychuk Added POST urlencoded body parsing
tj authored
74
fa08323 TJ Holowaychuk Markdown
tj authored
75 // POST /login
76
77 post('login', function() {
78 'Welcome ' + param('user').name
79 })
7807f42 TJ Holowaychuk Added POST urlencoded body parsing
tj authored
80
fa08323 TJ Holowaychuk Markdown
tj authored
81 ## Settings
204cea8 TJ Holowaychuk Added settings docs
tj authored
82
fa08323 TJ Holowaychuk Markdown
tj authored
83 * basepath : defaults to '/'
84 * defaultRoute : responds with page not found
85 * mime.defaultType : defaults to 'application/octet-stream'
86 * cookie.maxAge : defaults to 3600 milliseconds
204cea8 TJ Holowaychuk Added settings docs
tj authored
87
fa08323 TJ Holowaychuk Markdown
tj authored
88 ## Public API
8675f12 TJ Holowaychuk New doc files
tj authored
89
3a3be0f TJ Holowaychuk Coming soon (public api docs)
tj authored
90 * Coming Soon
fa08323 TJ Holowaychuk Markdown
tj authored
91
92 ## Testing
93
94 Install [JSpec](http://jspec.info), edit the path to JSpec on your machine, and run:
95
96 $ node spec/spec.node.js
8675f12 TJ Holowaychuk New doc files
tj authored
97
fa08323 TJ Holowaychuk Markdown
tj authored
98 ## License
8675f12 TJ Holowaychuk New doc files
tj authored
99
100 (The MIT License)
101
102 Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>
103
104 Permission is hereby granted, free of charge, to any person obtaining
105 a copy of this software and associated documentation files (the
106 'Software'), to deal in the Software without restriction, including
107 without limitation the rights to use, copy, modify, merge, publish,
108 distribute, sublicense, and/or sell copies of the Software, and to
109 permit persons to whom the Software is furnished to do so, subject to
110 the following conditions:
111
112 The above copyright notice and this permission notice shall be
113 included in all copies or substantial portions of the Software.
114
115 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
116 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
117 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
118 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
119 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
120 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
121 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.