Comparing version 1.1.0 to 1.1.1
@@ -44,2 +44,16 @@ var events = require('events'), | ||
// | ||
// ### function configure (options) | ||
// #### @options {Object} **Optional** Options to configure this instance with | ||
// Configures this instance with the specified `options`. | ||
// | ||
Router.prototype.configure = function (options) { | ||
options = options || {}; | ||
// useful when using connect's bodyParser | ||
this.stream = options.stream || false; | ||
director.Router.prototype.configure.call(this, options); | ||
} | ||
// | ||
// ### function on (method, path, route) | ||
@@ -61,3 +75,3 @@ // #### @method {string} **Optional** Method to use | ||
director.Router.prototype.on.call(this, method, path, route); | ||
director.Router.prototype.on.call(this, method, path, route); | ||
}; | ||
@@ -118,4 +132,4 @@ | ||
runlist = this.runlist(fns); | ||
stream = runlist.some(function (fn) { return fn.stream === true }); | ||
stream = this.stream || runlist.some(function (fn) { return fn.stream === true }); | ||
function parseAndInvoke() { | ||
@@ -135,3 +149,3 @@ error = self.parse(req); | ||
// | ||
// If there is no streaming required on any of the functions on the | ||
// If there is no streaming required on any of the functions on the | ||
// way to `path`, then attempt to parse the fully buffered request stream | ||
@@ -143,3 +157,3 @@ // once it has emitted the `end` event. | ||
// If the `http.ServerRequest` is still readable, then await | ||
// the end event and then continue | ||
// the end event and then continue | ||
// | ||
@@ -150,3 +164,3 @@ req.once('end', parseAndInvoke) | ||
// | ||
// Otherwise, just parse the body now. | ||
// Otherwise, just parse the body now. | ||
// | ||
@@ -153,0 +167,0 @@ parseAndInvoke(); |
@@ -5,3 +5,3 @@ { | ||
"author": "Nodejitsu Inc. <info@nodejitsu.com>", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"maintainers": [ | ||
@@ -8,0 +8,0 @@ "hij1nx <paolo@nodejitsu.com>", |
@@ -21,3 +21,3 @@ //reset these each test | ||
// | ||
// | ||
@@ -28,3 +28,3 @@ router.path('/a', function() { | ||
// you can continue to define the route structure (ad-hoc) and then assign units of logic | ||
// per event type, there will be less repetition of definition, and the code will be more | ||
// per event type, there will be less repetition of definition, and the code will be more | ||
// readable/centralized. | ||
@@ -31,0 +31,0 @@ |
@@ -178,3 +178,3 @@ | ||
// // // | ||
// // // | ||
// // // Recursion features | ||
@@ -354,3 +354,3 @@ // // // ---------------------------------------------------------- | ||
// // | ||
// // | ||
// // Special Events | ||
@@ -483,3 +483,3 @@ // // ---------------------------------------------------------- | ||
}, | ||
'/d': { | ||
'/d': { | ||
on: ['f1', 'f2'] | ||
@@ -486,0 +486,0 @@ } |
/* | ||
* dispatch-test.js: Tests for the core dispatch method. | ||
* dispatch-test.js: Tests for the core dispatch method. | ||
* | ||
@@ -8,7 +8,7 @@ * (C) 2011, Nodejitsu Inc. | ||
*/ | ||
var assert = require('assert'), | ||
vows = require('vows'), | ||
director = require('../../../lib/director'); | ||
vows.describe('director/cli/dispatch').addBatch({ | ||
@@ -19,3 +19,3 @@ "An instance of director.cli.Router": { | ||
that = this; | ||
that.matched = {}; | ||
@@ -28,3 +28,3 @@ that.matched['users'] = []; | ||
}); | ||
router.on(/apps (\w+\s\w+)/, function () { | ||
@@ -34,3 +34,3 @@ assert.equal(arguments.length, 1); | ||
}); | ||
return router; | ||
@@ -37,0 +37,0 @@ }, |
/* | ||
* dispatch-test.js: Tests for the core dispatch method. | ||
* dispatch-test.js: Tests for the core dispatch method. | ||
* | ||
@@ -8,7 +8,7 @@ * (C) 2011, Nodejitsu Inc. | ||
*/ | ||
var assert = require('assert'), | ||
vows = require('vows'), | ||
director = require('../../../lib/director'); | ||
vows.describe('director/cli/path').addBatch({ | ||
@@ -20,3 +20,3 @@ "An instance of director.cli.Router": { | ||
function noop () {} | ||
router.path(/apps/, function () { | ||
@@ -26,8 +26,8 @@ router.path(/foo/, function () { | ||
}); | ||
router.on(/list/, noop); | ||
}); | ||
router.on(/users/, noop); | ||
assert.isObject(router.routes.apps); | ||
@@ -34,0 +34,0 @@ assert.isFunction(router.routes.apps.list.on); |
/* | ||
* dispatch-test.js: Tests for the core dispatch method. | ||
* dispatch-test.js: Tests for the core dispatch method. | ||
* | ||
@@ -8,7 +8,7 @@ * (C) 2011, Nodejitsu Inc. | ||
*/ | ||
var assert = require('assert'), | ||
vows = require('vows'), | ||
director = require('../../../lib/director'); | ||
vows.describe('director/core/dispatch').addBatch({ | ||
@@ -22,3 +22,3 @@ "An instance of director.Router": { | ||
that.matched['f*'] = [] | ||
var router = new director.Router({ | ||
@@ -113,4 +113,4 @@ '/': { | ||
} | ||
} | ||
} | ||
} | ||
}).export(module); |
/* | ||
* insert-test.js: Tests for inserting routes into a normalized routing table. | ||
* insert-test.js: Tests for inserting routes into a normalized routing table. | ||
* | ||
@@ -12,3 +12,3 @@ * (C) 2011, Nodejitsu Inc. | ||
director = require('../../../lib/director'); | ||
vows.describe('director/core/insert').addBatch({ | ||
@@ -20,3 +20,3 @@ "An instance of director.Router": { | ||
function route () { } | ||
router.insert('on', ['foo', 'bar'], route); | ||
@@ -27,3 +27,3 @@ assert.strictEqual(router.routes.foo.bar.on, route); | ||
function route () { } | ||
router.insert('on', ['foo', 'bar'], route); | ||
@@ -35,3 +35,3 @@ assert.isArray(router.routes.foo.bar.on); | ||
function route () { } | ||
router.insert('on', ['foo', 'bar'], route); | ||
@@ -43,5 +43,5 @@ assert.isArray(router.routes.foo.bar.on); | ||
function route () { } | ||
router.insert('get', ['fizz', 'buzz'], route); | ||
assert.strictEqual(router.routes.fizz.buzz.get, route); | ||
assert.strictEqual(router.routes.fizz.buzz.get, route); | ||
} | ||
@@ -48,0 +48,0 @@ } |
@@ -12,3 +12,3 @@ /* | ||
director = require('../../../lib/director'); | ||
vows.describe('director/core/insert').addBatch({ | ||
@@ -20,3 +20,3 @@ "An instance of director.Router": { | ||
function noop () { } | ||
router.on(['foo', 'bar'], noop); | ||
@@ -28,3 +28,3 @@ assert.strictEqual(router.routes.foo.on, noop); | ||
function noop () { } | ||
router.on('baz', noop); | ||
@@ -35,3 +35,3 @@ assert.strictEqual(router.routes.baz.on, noop); | ||
function noop () { } | ||
router.on('after', 'boo', noop); | ||
@@ -38,0 +38,0 @@ assert.strictEqual(router.routes.boo.after, noop); |
/* | ||
* path-test.js: Tests for the core `.path()` method. | ||
* path-test.js: Tests for the core `.path()` method. | ||
* | ||
@@ -8,7 +8,7 @@ * (C) 2011, Nodejitsu Inc. | ||
*/ | ||
var assert = require('assert'), | ||
vows = require('vows'), | ||
director = require('../../../lib/director'); | ||
vows.describe('director/core/path').addBatch({ | ||
@@ -21,3 +21,3 @@ "An instance of director.Router": { | ||
that.matched['newyork'] = []; | ||
var router = new director.Router({ | ||
@@ -24,0 +24,0 @@ '/foo': function () { that.matched['foo'].push('foo'); } |
/* | ||
* index.js: Test helpers for director. | ||
* index.js: Test helpers for director. | ||
* | ||
@@ -34,7 +34,7 @@ * (C) 2011, Nodejitsu Inc. | ||
res = this.res; | ||
this.req.on('data', function (chunk) { | ||
body += chunk; | ||
}); | ||
this.req.on('end', function () { | ||
@@ -41,0 +41,0 @@ res.writeHead(200, { 'Content-Type': 'application/json' }); |
/* | ||
* macros.js: Test macros for director tests. | ||
* macros.js: Test macros for director tests. | ||
* | ||
@@ -8,3 +8,3 @@ * (C) 2011, Nodejitsu Inc. | ||
*/ | ||
var assert = require('assert'), | ||
@@ -19,3 +19,3 @@ request = require('request'); | ||
}; | ||
context['should respond with `' + expected + '`'] = function (err, res, body) { | ||
@@ -26,3 +26,3 @@ assert.isNull(err); | ||
}; | ||
return context; | ||
@@ -34,3 +34,3 @@ }; | ||
topic: function () { | ||
request({ | ||
request({ | ||
method: 'POST', | ||
@@ -37,0 +37,0 @@ uri: 'http://localhost:' + port + '/' + uri, |
@@ -8,3 +8,3 @@ /* | ||
*/ | ||
var assert = require('assert'), | ||
@@ -11,0 +11,0 @@ http = require('http'), |
/* | ||
* http-test.js: Tests for basic HTTP server(s). | ||
* http-test.js: Tests for basic HTTP server(s). | ||
* | ||
@@ -8,3 +8,3 @@ * (C) 2011, Nodejitsu Inc. | ||
*/ | ||
var assert = require('assert'), | ||
@@ -46,3 +46,3 @@ http = require('http'), | ||
}); | ||
helpers.createServer(router) | ||
@@ -49,0 +49,0 @@ .listen(9090, this.callback); |
/* | ||
* methods-test.js: Tests for HTTP methods. | ||
* methods-test.js: Tests for HTTP methods. | ||
* | ||
@@ -12,3 +12,3 @@ * (C) 2011, Nodejitsu Inc. | ||
director = require('../../../lib/director'); | ||
vows.describe('director/http/methods').addBatch({ | ||
@@ -28,10 +28,10 @@ "When using director": { | ||
function modifyResource() {} | ||
router.path(/\/resource/, function () { | ||
this.get(getResource); | ||
this.put(/\/update/, modifyResource); | ||
this.post(/create/, modifyResource); | ||
}); | ||
assert.equal(router.routes.resource.get, getResource); | ||
@@ -38,0 +38,0 @@ assert.equal(router.routes.resource.update.put, modifyResource); |
/* | ||
* responses-test.js: Tests for HTTP responses. | ||
* responses-test.js: Tests for HTTP responses. | ||
* | ||
@@ -8,7 +8,7 @@ * (C) 2011, Nodejitsu Inc. | ||
*/ | ||
var assert = require('assert'), | ||
vows = require('vows'), | ||
director = require('../../../lib/director'); | ||
vows.describe('director/http/responses').addBatch({ | ||
@@ -15,0 +15,0 @@ "When using director.http": { |
@@ -8,3 +8,3 @@ /* | ||
*/ | ||
var assert = require('assert'), | ||
@@ -18,3 +18,3 @@ http = require('http'), | ||
handlers = helpers.handlers | ||
vows.describe('director/http/stream').addBatch({ | ||
@@ -21,0 +21,0 @@ "An instance of director.http.Router": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
284428
4833