Skip to content
Myr

Added `app.routes.all()`. Closes #803

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

not a huge fan of this API-wise, but at least it is something for now

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 3c2139b · Browse files · 2 files+25 added−1 removed
This commit

State

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

Diff stats

2 files+25 added−1 removed

  • tests:+12 added−1 removed
  • other:+13 added−0 removed

2 files+25 added−1 removed

modified:lib/router/index.js+13 added
82 unmodified lines
83 return this;84};8586/**87 * Return a `Collection` of all routes defined.88 *89 * @return {Collection}90 * @api public91 */9293Router.prototype.all = function(){94 return this.find(function(){95 return true;96 });97};9899/**100 * Remove the given `route`, returns101 * a bool indicating if the route was present102 * or not.103 *
307 unmodified lines
modified:test/router.test.js+12 added-1 removed
596 unmodified lines
597 app.match.get('/').should.have.be.empty;598 app.match.all('/user/123').should.have.length(3);599 app.match('/user/123').should.have.length(3);600 },601 601602 'test app.routes.all()': function(){603 var app = express.createServer();604 app.get('/user', function(){});605 app.get('/user/:id', function(){});606 app.get('/user/:id/:op?', function(){});607 app.put('/user/:id', function(){});608 app.get('/user/:id/edit', function(){});609 app.routes.all()[0].should.be.an.instanceof(Route);610 app.routes.all().length.should.equal(5);611 },612613 'test Collection': function(){614 var app = express.createServer();615 app.get('/user', function(){});616 app.get('/user/:id', function(){});
97 unmodified lines