Skip to content

Commit

Permalink
Fixed more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jun 25, 2010
1 parent 26da7b2 commit 9a631aa
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 21 deletions.
30 changes: 15 additions & 15 deletions lib/connect/middleware/router.js
Expand Up @@ -12,10 +12,22 @@
var parse = require('url').parse;

/**
* Setup routes.
* Provides Sinatra and Express like routing capabilities.
*
* Examples:
*
* connect.router(function(app){
* app.get('/user/:id', function(req, res, params){
* // populates params.id
* });
* })
*
* @param {Function} fn
* @return {Function}
* @api public
*/

module.exports = function setup(fn) {
module.exports = function(fn){
var routes;

if (fn) {
Expand All @@ -30,14 +42,6 @@ module.exports = function setup(fn) {
throw new Error('router provider requires a callback function');
}

/**
* Return a routing function.
*
* @param {String} name
* @return {Function}
* @api private
*/

function method(name) {
var self = this,
localRoutes = routes[name] = routes[name] || [];
Expand All @@ -51,11 +55,7 @@ module.exports = function setup(fn) {
};
}


/**
* Attempt to match and call a route.
*/
return function handle(req, res, next) {
return function(req, res, next){
var self = this;
process.nextTick(function(){
var route;
Expand Down
5 changes: 4 additions & 1 deletion lib/connect/middleware/session.js
Expand Up @@ -20,6 +20,9 @@ var MemoryStore = require('./session/memory').MemoryStore,
* - `store` Session store instance
* - `fingerprint` Custom fingerprint hashing function
*
* @param {Object} options
* @return {Function}
* @api public
*/

module.exports = function(options){
Expand All @@ -35,7 +38,7 @@ module.exports = function(options){
+ (req.headers['user-agent'] || '');
};

return function handle(req, res, next){
return function(req, res, next){
// Expose store
req.sessionStore = store;

Expand Down
23 changes: 19 additions & 4 deletions lib/connect/middleware/staticProvider.js
@@ -1,26 +1,41 @@

/*!
* Ext JS Connect
* Copyright(c) 2010 Ext JS, Inc.
* MIT Licensed
*/

/**
* Module dependencies.
*/

var fs = require('fs'),
Url = require('url'),
Buffer = require('buffer').Buffer,
Path = require('path'),
utils = require('./../utils');

var lifetime = 1000 * 60 * 60; // 1 hour browser cache lifetime
/**
* Browser cache lifetime of one hour.
*
* @type Number
*/

var lifetime = 1000 * 60 * 60;

/**
* Setup static file server.
* Static file server.
*
* Options:
*
* - root Root path from which to serve static files.
* - `root` Root path from which to serve static files.
*
* @param {String} root
* @return {Function}
* @api public
*/

module.exports = function setup(root) {
module.exports = function(root){
root = process.connectEnv.staticRoot || root || process.cwd();
return function handle(req, res, next) {
var url = Url.parse(req.url);
Expand Down
18 changes: 17 additions & 1 deletion lib/connect/middleware/vhost.js
Expand Up @@ -6,7 +6,23 @@
*/

/**
* Setup vhost.
* Setup vhost for the given `hostname` and `server`.
*
* Examples:
*
* connect.createServer(
* connect.vhost('foo.com',
* connect.createServer(...middleware...)
* ),
* connect.vhost('bar.com',
* connect.createServer(...middleware...)
* )
* );
*
* @param {String} hostname
* @param {Server} server
* @return {Function}
* @api public
*/

module.exports = function(hostname, server){
Expand Down

0 comments on commit 9a631aa

Please sign in to comment.