Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-trie-router

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-trie-router - npm Package Compare versions

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
}

4

lib/dispatcher.js

@@ -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) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc