koa-route
Advanced tools
Comparing version 3.0.0 to 3.1.0
3.0.0 / 2015-11-17 | ||
=================== | ||
* update to promise-based middleware | ||
2.4.2 / 2015-07-02 | ||
@@ -3,0 +8,0 @@ =================== |
34
index.js
@@ -26,18 +26,26 @@ | ||
return function (ctx, next){ | ||
// method | ||
if (!matches(ctx, method)) return next(); | ||
const createRoute = function(routeFunc){ | ||
return function (ctx, next){ | ||
// method | ||
if (!matches(ctx, method)) return next(); | ||
// path | ||
const m = re.exec(ctx.path); | ||
if (m) { | ||
const args = m.slice(1).map(decode); | ||
debug('%s %s matches %s %j', ctx.method, path, ctx.path, args); | ||
args.unshift(ctx); | ||
args.push(next); | ||
return Promise.resolve(fn.apply(ctx, args)); | ||
// path | ||
const m = re.exec(ctx.path); | ||
if (m) { | ||
const args = m.slice(1).map(decode); | ||
debug('%s %s matches %s %j', ctx.method, path, ctx.path, args); | ||
args.unshift(ctx); | ||
args.push(next); | ||
return Promise.resolve(routeFunc.apply(ctx, args)); | ||
} | ||
// miss | ||
return next(); | ||
} | ||
}; | ||
// miss | ||
return next(); | ||
if (fn) { | ||
return createRoute(fn); | ||
} else { | ||
return createRoute; | ||
} | ||
@@ -44,0 +52,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"repository": "koajs/route", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "koa", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
4468
56
0