Skip to content
Myr

remove generated docs

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 75debbe · Browse files · 5 files+1 added−1025 removed
This commit

State

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

Diff stats

5 files+1 added−1025 removed

  • other:+1 added−1025 removed

5 files+1 added−1025 removed

deleted:docs/application.md-181 removed
12# app34 Application prototype.56# app.use()78 Proxy `connect#use()` to apply settings to9 mounted applications.1011# app.engine()1213 Register the given template engine callback `fn`14 as `ext`.15 16 By default will `require()` the engine based on the17 file extension. For example if you try to render18 a "foo.jade" file Express will invoke the following internally:19 20 app.engine('jade', require('jade').__express);21 22 For engines that do not provide `.__express` out of the box,23 or if you wish to "map" a different extension to the template engine24 you may use this method. For example mapping the EJS template engine to25 ".html" files26 27 app.engine('html', require('ejs').renderFile);28 29 In this case EJS provides a `.renderFile()` method with30 the same signature that Express expects: `(path, options, callback)`,31 though note that it aliases this method as `ejs.__express` internally32 so if you're using ".ejs" extensions you dont need to do anything.33 34 Some template engines do not follow this convention, the35 [Consolidate.js](https://github.com/visionmedia/consolidate.js)36 library was created to map all of node's popular template37 engines to follow this convention, thus allowing them to38 work seemlessly within Express.3940# app.param()4142 Map the given param placeholder `name`(s) to the given callback(s).43 44 Parameter mapping is used to provide pre-conditions to routes45 which use normalized placeholders. For example a _:user_id_ parameter46 could automatically load a user's information from the database without47 any additional code,48 49 The callback uses the samesignature as middleware, the only differencing50 being that the value of the placeholder is passed, in this case the _id_51 of the user. Once the `next()` function is invoked, just like middleware52 it will continue on to execute the route, or subsequent parameter functions.53 54 app.param('user_id', function(req, res, next, id){55 User.find(id, function(err, user){56 if (err) {57 next(err);58 } else if (user) {59 req.user = user;60 next();61 } else {62 next(new Error('failed to load user'));63 }64 });65 });6667# app.set()6869 Assign `setting` to `val`, or return `setting`'s value.70 71 app.set('foo', 'bar');72 app.get('foo');73 // => "bar"74 75 Mounted servers inherit their parent server's settings.7677# app.enabled()7879 Check if `setting` is enabled (truthy).80 81 app.enabled('foo')82 // => false83 84 app.enable('foo')85 app.enabled('foo')86 // => true8788# app.disabled()8990 Check if `setting` is disabled.91 92 app.disabled('foo')93 // => true94 95 app.enable('foo')96 app.disabled('foo')97 // => false9899# app.enable()100101 Enable `setting`.102103# app.disable()104105 Disable `setting`.106107# app.configure()108109 Configure callback for zero or more envs,110 when no `env` is specified that callback will111 be invoked for all environments. Any combination112 can be used multiple times, in any order desired.113 114 ## Examples115 116 app.configure(function(){117 // executed for all envs118 });119 120 app.configure('stage', function(){121 // executed staging env122 });123 124 app.configure('stage', 'production', function(){125 // executed for stage and production126 });127 128 ## Note129 130 These callbacks are invoked immediately, and131 are effectively sugar for the following.132 133 var env = process.env.NODE_ENV || 'development';134 135 switch (env) {136 case 'development':137 ...138 break;139 case 'stage':140 ...141 break;142 case 'production':143 ...144 break;145 }146147# app.all()148149 Special-cased "all" method, applying the given route `path`,150 middleware, and callback to _every_ HTTP method.151152# app.render()153154 Render the given view `name` name with `options`155 and a callback accepting an error and the156 rendered template string.157 158 ## Example159 160 app.render('email', { name: 'Tobi' }, function(err, html){161 // ...162 })163164# app.listen()165166 Listen for connections.167 168 A node `http.Server` is returned, with this169 application (which is a `Function`) as its170 callback. If you wish to create both an HTTP171 and HTTPS server you may do so with the "http"172 and "https" modules as shown here.173 174 var http = require('http')175 , https = require('https')176 , express = require('express')177 , app = express();178 179 http.createServer(app).listen(80);180 http.createServer({ ... }, app).listen(443);181
deleted:docs/express.md-506 removed
12# app34 Application prototype.56# app.use()78 Proxy `connect#use()` to apply settings to9 mounted applications.1011# app.engine()1213 Register the given template engine callback `fn`14 as `ext`.15 16 By default will `require()` the engine based on the17 file extension. For example if you try to render18 a "foo.jade" file Express will invoke the following internally:19 20 app.engine('jade', require('jade').__express);21 22 For engines that do not provide `.__express` out of the box,23 or if you wish to "map" a different extension to the template engine24 you may use this method. For example mapping the EJS template engine to25 ".html" files26 27 app.engine('html', require('ejs').renderFile);28 29 In this case EJS provides a `.renderFile()` method with30 the same signature that Express expects: `(path, options, callback)`,31 though note that it aliases this method as `ejs.__express` internally32 so if you're using ".ejs" extensions you dont need to do anything.33 34 Some template engines do not follow this convention, the35 [Consolidate.js](https://github.com/visionmedia/consolidate.js)36 library was created to map all of node's popular template37 engines to follow this convention, thus allowing them to38 work seemlessly within Express.3940# app.param()4142 Map the given param placeholder `name`(s) to the given callback(s).43 44 Parameter mapping is used to provide pre-conditions to routes45 which use normalized placeholders. For example a _:user_id_ parameter46 could automatically load a user's information from the database without47 any additional code,48 49 The callback uses the samesignature as middleware, the only differencing50 being that the value of the placeholder is passed, in this case the _id_51 of the user. Once the `next()` function is invoked, just like middleware52 it will continue on to execute the route, or subsequent parameter functions.53 54 app.param('user_id', function(req, res, next, id){55 User.find(id, function(err, user){56 if (err) {57 next(err);58 } else if (user) {59 req.user = user;60 next();61 } else {62 next(new Error('failed to load user'));63 }64 });65 });6667# app.set()6869 Assign `setting` to `val`, or return `setting`'s value.70 71 app.set('foo', 'bar');72 app.get('foo');73 // => "bar"74 75 Mounted servers inherit their parent server's settings.7677# app.enabled()7879 Check if `setting` is enabled (truthy).80 81 app.enabled('foo')82 // => false83 84 app.enable('foo')85 app.enabled('foo')86 // => true8788# app.disabled()8990 Check if `setting` is disabled.91 92 app.disabled('foo')93 // => true94 95 app.enable('foo')96 app.disabled('foo')97 // => false9899# app.enable()100101 Enable `setting`.102103# app.disable()104105 Disable `setting`.106107# app.configure()108109 Configure callback for zero or more envs,110 when no `env` is specified that callback will111 be invoked for all environments. Any combination112 can be used multiple times, in any order desired.113 114 ## Examples115 116 app.configure(function(){117 // executed for all envs118 });119 120 app.configure('stage', function(){121 // executed staging env122 });123 124 app.configure('stage', 'production', function(){125 // executed for stage and production126 });127 128 ## Note129 130 These callbacks are invoked immediately, and131 are effectively sugar for the following.132 133 var env = process.env.NODE_ENV || 'development';134 135 switch (env) {136 case 'development':137 ...138 break;139 case 'stage':140 ...141 break;142 case 'production':143 ...144 break;145 }146147# app.all()148149 Special-cased "all" method, applying the given route `path`,150 middleware, and callback to _every_ HTTP method.151152# app.render()153154 Render the given view `name` name with `options`155 and a callback accepting an error and the156 rendered template string.157 158 ## Example159 160 app.render('email', { name: 'Tobi' }, function(err, html){161 // ...162 })163164# app.listen()165166 Listen for connections.167 168 A node `http.Server` is returned, with this169 application (which is a `Function`) as its170 callback. If you wish to create both an HTTP171 and HTTPS server you may do so with the "http"172 and "https" modules as shown here.173 174 var http = require('http')175 , https = require('https')176 , express = require('express')177 , app = express();178 179 http.createServer(app).listen(80);180 http.createServer({ ... }, app).listen(443);181182183# req184185 Request prototype.186187# req.get188189 Return request header.190 191 The `Referrer` header field is special-cased,192 both `Referrer` and `Referer` are interchangeable.193 194 ## Examples195 196 req.get('Content-Type');197 // => "text/plain"198 199 req.get('content-type');200 // => "text/plain"201 202 req.get('Something');203 // => undefined204 205 Aliased as `req.header()`.206207# req.accepts()208209 Check if the given `type(s)` is acceptable, returning210 the best match when true, otherwise `undefined`, in which211 case you should respond with 406 "Not Acceptable".212 213 The `type` value may be a single mime type string214 such as "application/json", the extension name215 such as "json", a comma-delimted list such as "json, html, text/plain",216 or an array `["json", "html", "text/plain"]`. When a list217 or array is given the _best_ match, if any is returned.218 219 ## Examples220 221 // Accept: text/html222 req.accepts('html');223 // => "html"224 225 // Accept: text/*, application/json226 req.accepts('html');227 // => "html"228 req.accepts('text/html');229 // => "text/html"230 req.accepts('json, text');231 // => "json"232 req.accepts('application/json');233 // => "application/json"234 235 // Accept: text/*, application/json236 req.accepts('image/png');237 req.accepts('png');238 // => undefined239 240 // Accept: text/*;q=.5, application/json241 req.accepts(['html', 'json']);242 req.accepts('html, json');243 // => "json"244245# req.acceptsCharset()246247 Check if the given `charset` is acceptable,248 otherwise you should respond with 406 "Not Acceptable".249250# req.acceptsLanguage()251252 Check if the given `lang` is acceptable,253 otherwise you should respond with 406 "Not Acceptable".254255# req.param()256257 Return the value of param `name` when present or `defaultValue`.258 259 - Checks route placeholders, ex: _/user/:id_260 - Checks body params, ex: id=12, {"id":12}261 - Checks query string params, ex: ?id=12262 263 To utilize request bodies, `req.body`264 should be an object. This can be done by using265 the `connect.bodyParser()` middleware.266267# req.is()268269 Check if the incoming request contains the "Content-Type" 270 header field, and it contains the give mime `type`.271 272 ## Examples273 274 // With Content-Type: text/html; charset=utf-8275 req.is('html');276 req.is('text/html');277 req.is('text/*');278 // => true279 280 // When Content-Type is application/json281 req.is('json');282 req.is('application/json');283 req.is('application/*');284 // => true285 286 req.is('html');287 // => false288289290# res291292 Response prototype.293294# res.status()295296 Set status `code`.297298# res.send()299300 Send a response.301 302 ## Examples303 304 res.send(new Buffer('wahoo'));305 res.send({ some: 'json' });306 res.send('<p>some html</p>');307 res.send(404, 'Sorry, cant find that');308 res.send(404);309310# res.json()311312 Send JSON response.313 314 ## Examples315 316 res.json(null);317 res.json({ user: 'tj' });318 res.json(500, 'oh noes!');319 res.json(404, 'I dont have that');320321# res.sendfile()322323 Transfer the file at the given `path`.324 325 Automatically sets the _Content-Type_ response header field.326 The callback `fn(err)` is invoked when the transfer is complete327 or when an error occurs. Be sure to check `res.sentHeader`328 if you wish to attempt responding, as the header and some data329 may have already been transferred.330 331 ## Options332 333 - `maxAge` defaulting to 0334 - `root` root directory for relative filenames335 336 ## Examples337 338 The following example illustrates how `res.sendfile()` may339 be used as an alternative for the `static()` middleware for340 dynamic situations. The code backing `res.sendfile()` is actually341 the same code, so HTTP cache support etc is identical.342 343 app.get('/user/:uid/photos/:file', function(req, res){344 var uid = req.params.uid345 , file = req.params.file;346 347 req.user.mayViewFilesFrom(uid, function(yes){348 if (yes) {349 res.sendfile('/uploads/' + uid + '/' + file);350 } else {351 res.send(403, 'Sorry! you cant see that.');352 }353 });354 });355356# res.download()357358 Transfer the file at the given `path` as an attachment.359 360 Optionally providing an alternate attachment `filename`,361 and optional callback `fn(err)`. The callback is invoked362 when the data transfer is complete, or when an error has363 ocurred. Be sure to check `res.headerSent` if you plan to respond.364 365 This method uses `res.sendfile()`.366367# res.format()368369 Respond to the Acceptable formats using an `obj`370 of mime-type callbacks.371 372 This method uses `req.accepted`, an array of373 acceptable types ordered by their quality values.374 When "Accept" is not present the _first_ callback375 is invoked, otherwise the first match is used. When376 no match is performed the server responds with377 406 "Not Acceptable".378 379 Content-Type is set for you, however if you choose380 you may alter this within the callback using `res.type()`381 or `res.set('Content-Type', ...)`.382 383 res.format({384 'text/plain': function(){385 res.send('hey');386 },387 388 'text/html': function(){389 res.send('<p>hey</p>');390 },391 392 'appliation/json': function(){393 res.send({ message: 'hey' });394 }395 });396 397 In addition to canonicalized MIME types you may398 also use extnames mapped to these types:399 400 res.format({401 text: function(){402 res.send('hey');403 },404 405 html: function(){406 res.send('<p>hey</p>');407 },408 409 json: function(){410 res.send({ message: 'hey' });411 }412 });413 414 By default Express passes an `Error`415 with a `.status` of 406 to `next(err)`416 if a match is not made, however you may417 provide an optional callback `fn` to418 be invoked instead.419420# res.attachment()421422 Set _Content-Disposition_ header to _attachment_ with optional `filename`.423424# res.set425426 Set header `field` to `val`, or pass427 an object of header fields.428 429 ## Examples430 431 res.set('Accept', 'application/json');432 res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });433 434 Aliased as `res.header()`.435436# res.get()437438 Get value for header `field`.439440# res.clearCookie()441442 Clear cookie `name`.443444# res.cookie()445446 Set cookie `name` to `val`, with the given `options`.447 448 ## Options449 450 - `maxAge` max-age in milliseconds, converted to `expires`451 - `signed` sign the cookie452 - `path` defaults to "/"453 454 ## Examples455 456 // "Remember Me" for 15 minutes457 res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });458 459 // save as above460 res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })461462# res.redirect()463464 Redirect to the given `url` with optional response `status`465 defaulting to 302.466 467 The given `url` can also be the name of a mapped url, for468 example by default express supports "back" which redirects469 to the _Referrer_ or _Referer_ headers or "/".470 471 ## Examples472 473 res.redirect('/foo/bar');474 res.redirect('http://example.com');475 res.redirect(301, 'http://example.com');476 res.redirect('../login'); // /blog/post/1 -> /blog/login477 478 ## Mounting479 480 When an application is mounted, and `res.redirect()`481 is given a path that does _not_ lead with "/". For 482 example suppose a "blog" app is mounted at "/blog",483 the following redirect would result in "/blog/login":484 485 res.redirect('login');486 487 While the leading slash would result in a redirect to "/login":488 489 res.redirect('/login');490491# res.render()492493 Render `view` with the given `options` and optional callback `fn`.494 When a callback function is given a response will _not_ be made495 automatically, otherwise a response of _200_ and _text/html_ is given.496 497 ## Options498 499 - `status` Response status code (`res.statusCode`)500 - `charset` Set the charset (`res.charset`)501 502 ## Reserved locals503 504 - `cache` boolean hinting to the engine it should cache505 - `filename` filename of the view being rendered506
deleted:docs/request.md-107 removed
12# req34 Request prototype.56# req.get78 Return request header.9 10 The `Referrer` header field is special-cased,11 both `Referrer` and `Referer` are interchangeable.12 13 ## Examples14 15 req.get('Content-Type');16 // => "text/plain"17 18 req.get('content-type');19 // => "text/plain"20 21 req.get('Something');22 // => undefined23 24 Aliased as `req.header()`.2526# req.accepts()2728 Check if the given `type(s)` is acceptable, returning29 the best match when true, otherwise `undefined`, in which30 case you should respond with 406 "Not Acceptable".31 32 The `type` value may be a single mime type string33 such as "application/json", the extension name34 such as "json", a comma-delimted list such as "json, html, text/plain",35 or an array `["json", "html", "text/plain"]`. When a list36 or array is given the _best_ match, if any is returned.37 38 ## Examples39 40 // Accept: text/html41 req.accepts('html');42 // => "html"43 44 // Accept: text/*, application/json45 req.accepts('html');46 // => "html"47 req.accepts('text/html');48 // => "text/html"49 req.accepts('json, text');50 // => "json"51 req.accepts('application/json');52 // => "application/json"53 54 // Accept: text/*, application/json55 req.accepts('image/png');56 req.accepts('png');57 // => undefined58 59 // Accept: text/*;q=.5, application/json60 req.accepts(['html', 'json']);61 req.accepts('html, json');62 // => "json"6364# req.acceptsCharset()6566 Check if the given `charset` is acceptable,67 otherwise you should respond with 406 "Not Acceptable".6869# req.acceptsLanguage()7071 Check if the given `lang` is acceptable,72 otherwise you should respond with 406 "Not Acceptable".7374# req.param()7576 Return the value of param `name` when present or `defaultValue`.77 78 - Checks route placeholders, ex: _/user/:id_79 - Checks body params, ex: id=12, {"id":12}80 - Checks query string params, ex: ?id=1281 82 To utilize request bodies, `req.body`83 should be an object. This can be done by using84 the `connect.bodyParser()` middleware.8586# req.is()8788 Check if the incoming request contains the "Content-Type" 89 header field, and it contains the give mime `type`.90 91 ## Examples92 93 // With Content-Type: text/html; charset=utf-894 req.is('html');95 req.is('text/html');96 req.is('text/*');97 // => true98 99 // When Content-Type is application/json100 req.is('json');101 req.is('application/json');102 req.is('application/*');103 // => true104 105 req.is('html');106 // => false107
deleted:docs/response.md-218 removed
12# res34 Response prototype.56# res.status()78 Set status `code`.910# res.send()1112 Send a response.13 14 ## Examples15 16 res.send(new Buffer('wahoo'));17 res.send({ some: 'json' });18 res.send('<p>some html</p>');19 res.send(404, 'Sorry, cant find that');20 res.send(404);2122# res.json()2324 Send JSON response.25 26 ## Examples27 28 res.json(null);29 res.json({ user: 'tj' });30 res.json(500, 'oh noes!');31 res.json(404, 'I dont have that');3233# res.sendfile()3435 Transfer the file at the given `path`.36 37 Automatically sets the _Content-Type_ response header field.38 The callback `fn(err)` is invoked when the transfer is complete39 or when an error occurs. Be sure to check `res.sentHeader`40 if you wish to attempt responding, as the header and some data41 may have already been transferred.42 43 ## Options44 45 - `maxAge` defaulting to 046 - `root` root directory for relative filenames47 48 ## Examples49 50 The following example illustrates how `res.sendfile()` may51 be used as an alternative for the `static()` middleware for52 dynamic situations. The code backing `res.sendfile()` is actually53 the same code, so HTTP cache support etc is identical.54 55 app.get('/user/:uid/photos/:file', function(req, res){56 var uid = req.params.uid57 , file = req.params.file;58 59 req.user.mayViewFilesFrom(uid, function(yes){60 if (yes) {61 res.sendfile('/uploads/' + uid + '/' + file);62 } else {63 res.send(403, 'Sorry! you cant see that.');64 }65 });66 });6768# res.download()6970 Transfer the file at the given `path` as an attachment.71 72 Optionally providing an alternate attachment `filename`,73 and optional callback `fn(err)`. The callback is invoked74 when the data transfer is complete, or when an error has75 ocurred. Be sure to check `res.headerSent` if you plan to respond.76 77 This method uses `res.sendfile()`.7879# res.format()8081 Respond to the Acceptable formats using an `obj`82 of mime-type callbacks.83 84 This method uses `req.accepted`, an array of85 acceptable types ordered by their quality values.86 When "Accept" is not present the _first_ callback87 is invoked, otherwise the first match is used. When88 no match is performed the server responds with89 406 "Not Acceptable".90 91 Content-Type is set for you, however if you choose92 you may alter this within the callback using `res.type()`93 or `res.set('Content-Type', ...)`.94 95 res.format({96 'text/plain': function(){97 res.send('hey');98 },99 100 'text/html': function(){101 res.send('<p>hey</p>');102 },103 104 'appliation/json': function(){105 res.send({ message: 'hey' });106 }107 });108 109 In addition to canonicalized MIME types you may110 also use extnames mapped to these types:111 112 res.format({113 text: function(){114 res.send('hey');115 },116 117 html: function(){118 res.send('<p>hey</p>');119 },120 121 json: function(){122 res.send({ message: 'hey' });123 }124 });125 126 By default Express passes an `Error`127 with a `.status` of 406 to `next(err)`128 if a match is not made, however you may129 provide an optional callback `fn` to130 be invoked instead.131132# res.attachment()133134 Set _Content-Disposition_ header to _attachment_ with optional `filename`.135136# res.set137138 Set header `field` to `val`, or pass139 an object of header fields.140 141 ## Examples142 143 res.set('Accept', 'application/json');144 res.set({ Accept: 'text/plain', 'X-API-Key': 'tobi' });145 146 Aliased as `res.header()`.147148# res.get()149150 Get value for header `field`.151152# res.clearCookie()153154 Clear cookie `name`.155156# res.cookie()157158 Set cookie `name` to `val`, with the given `options`.159 160 ## Options161 162 - `maxAge` max-age in milliseconds, converted to `expires`163 - `signed` sign the cookie164 - `path` defaults to "/"165 166 ## Examples167 168 // "Remember Me" for 15 minutes169 res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });170 171 // save as above172 res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })173174# res.redirect()175176 Redirect to the given `url` with optional response `status`177 defaulting to 302.178 179 The given `url` can also be the name of a mapped url, for180 example by default express supports "back" which redirects181 to the _Referrer_ or _Referer_ headers or "/".182 183 ## Examples184 185 res.redirect('/foo/bar');186 res.redirect('http://example.com');187 res.redirect(301, 'http://example.com');188 res.redirect('../login'); // /blog/post/1 -> /blog/login189 190 ## Mounting191 192 When an application is mounted, and `res.redirect()`193 is given a path that does _not_ lead with "/". For 194 example suppose a "blog" app is mounted at "/blog",195 the following redirect would result in "/blog/login":196 197 res.redirect('login');198 199 While the leading slash would result in a redirect to "/login":200 201 res.redirect('/login');202203# res.render()204205 Render `view` with the given `options` and optional callback `fn`.206 When a callback function is given a response will _not_ be made207 automatically, otherwise a response of _200_ and _text/html_ is given.208 209 ## Options210 211 - `status` Response status code (`res.statusCode`)212 - `charset` Set the charset (`res.charset`)213 214 ## Reserved locals215 216 - `cache` boolean hinting to the engine it should cache217 - `filename` filename of the view being rendered218
modified:Makefile+1 added-13 removed
12MOCHA_OPTS=3REPORTER = dot45docs: docs/express.md67docs/express.md: docs/application.md docs/request.md docs/response.md8 cat $^ > $@910docs/%.md: lib/%.js11 @mkdir -p docs12 dox --raw < $< | ./support/docs > $@135check: test67test: test-unit test-acceptance8
13 unmodified lines
2223lib-cov:24 @jscoverage lib lib-cov2535docclean:36 rm -fr docs3726benchmark:27 @./support/bench2841.PHONY: docs docclean test test-unit test-acceptance benchmark29.PHONY: test test-unit test-acceptance benchmark