diet-router
Advanced tools
Comparing version 1.0.2 to 1.0.3
10
index.js
@@ -5,3 +5,3 @@ function Router (...middleware) { | ||
fn.path = path | ||
fn.middleware = [...fn.middleware, ...middleware] | ||
fn.middleware = [...middleware, ...fn.middleware] | ||
for (const op of fn.queue) { | ||
@@ -22,5 +22,11 @@ method.call(fn, op.method, op.path, op.middleware) | ||
get: function (target, name) { | ||
if (target.hasOwnProperty(name)) { | ||
if (typeof name === 'symbol') { | ||
return target[name] | ||
} | ||
if (name === 'inspect') { | ||
return target.inspect | ||
} | ||
if (name in target) { | ||
return target[name] | ||
} | ||
return function(path, ...middleware) { | ||
@@ -27,0 +33,0 @@ method.call(this, name, path, middleware) |
{ | ||
"name": "diet-router", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Simple, full featured, nestable router for diet.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -63,2 +63,4 @@ # diet-router | ||
Note that the router is the *last* argument passed | ||
Alternatively: | ||
@@ -71,3 +73,2 @@ | ||
Note that the router is the *last* argument passed using either method | ||
@@ -108,1 +109,6 @@ ## Nested Routing ## | ||
``` | ||
Contact | ||
------- | ||
Bug reports, feature requests, and questions are all welcome. Just open a GitHub issue and I'll | ||
get back to you |
@@ -35,2 +35,17 @@ const test = require('tape') | ||
test('Expect to be able to console.log a router without breaking everything', function (t) { | ||
try { | ||
const router = Router() | ||
console.log(router) | ||
router.get('/', function ($) { | ||
$.end('test success') | ||
}) | ||
app.route('/test0', router) | ||
t.pass('yes') | ||
t.end() | ||
} catch (err) { | ||
ErrHandler(t)(err) | ||
} | ||
}) | ||
test('Expect router to add an accessible route when the router is called directly and when methods are called before the router', function (t) { | ||
@@ -37,0 +52,0 @@ const router = Router() |
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
294
112
12929
5