koa-trie-router
Advanced tools
Comparing version 1.0.2 to 1.0.3
21
index.js
@@ -1,4 +0,21 @@ | ||
module.exports = require('./lib/router') | ||
var Router = exports.Router = require('./lib/router') | ||
require('./lib/routes') | ||
require('./lib/dispatcher') | ||
require('./lib/dispatcher') | ||
module.exports = function (app, options) { | ||
var router = new Router(app, options || {}) | ||
app.router = router.dispatcher() | ||
app.router.router = router | ||
app.router.define = function (str) { | ||
return router.trie.define(str) | ||
} | ||
app.router.match = function (str) { | ||
return router.trie.match(str) | ||
} | ||
app.context.assertImplementsMethod = router.assertImplementsMethod() | ||
return app.router | ||
} |
@@ -6,3 +6,3 @@ var Router = require('./router') | ||
return function* (next) { | ||
return function* trieRouter (next) { | ||
var match = trie.match(this.request.path) | ||
@@ -38,2 +38,2 @@ var node = match && match.node | ||
} | ||
} | ||
} |
@@ -6,5 +6,2 @@ var routington = require('routington') | ||
function Router(app) { | ||
if (!(this instanceof Router)) | ||
return new Router(app) | ||
this.app = app | ||
@@ -15,20 +12,4 @@ this.methods = { | ||
var trie = this.trie = routington() | ||
this.trie = routington() | ||
this.routes() | ||
// meh | ||
app.router = this.dispatcher() | ||
app.router.router = this | ||
// don't like this | ||
app.router.define = function (str) { | ||
return trie.define(str) | ||
} | ||
// don't like this | ||
app.router.match = function (str) { | ||
return trie.match(str) | ||
} | ||
// gah | ||
app.context.assertImplementsMethod = this.assertImplementsMethod() | ||
return app | ||
} | ||
@@ -41,5 +22,5 @@ | ||
if (!methods[this.method]) | ||
this.error(501, this.method + ' is not implemented') | ||
this.throw(501, this.method + ' is not implemented') | ||
return this | ||
} | ||
} | ||
} |
{ | ||
"name": "koa-trie-router", | ||
"description": "Trie-routing for Koa", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Jonathan Ong", |
@@ -18,6 +18,4 @@ # Koa Trie Router [![Build Status](https://travis-ci.org/koajs/trie-router.png)](https://travis-ci.org/koajs/trie-router) | ||
var app = require('koa')() | ||
require('koa-trie-router')(app) | ||
app.use(require('koa-trie-router')(app)) | ||
app.use(app.router) | ||
app.route('/') | ||
@@ -24,0 +22,0 @@ .get(function* (next) { |
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
9168
158
130