lark-router
Advanced tools
Comparing version 0.4.1 to 0.4.2
18
index.js
@@ -20,2 +20,3 @@ var rd = require('rd'); | ||
var bootstrap = function (options) { | ||
var app = this | ||
if (used) return function*(next) { | ||
@@ -49,4 +50,3 @@ yield next | ||
var router = new Router(); | ||
//require(file.dirname)(router); | ||
addRouter(file.dirname, router); | ||
addRouter.call(app, file.dirname, router); | ||
routers.push(mount(route, router.middleware())); | ||
@@ -64,3 +64,3 @@ }); | ||
if ('object' !== typeof controller) { | ||
return addRoutePath(router, controller); | ||
return addRoutePath.call(this, router, controller); | ||
} | ||
@@ -78,3 +78,3 @@ if (Array.isArray(controller)) { | ||
var handler = paths[routePath]; | ||
addRoutePath(router, method, routePath, handler); | ||
addRoutePath.call(this, router, method, routePath, handler); | ||
} | ||
@@ -85,6 +85,6 @@ } | ||
function addRoutePath (router, _method, _routePath, _handler) { | ||
handler = _handler || _routePath || _method; | ||
routePath = !!_handler ? _routePath : '/'; | ||
method = !!_routePath ? _method.toLowerCase() : 'get'; | ||
function addRoutePath (router, method, routePath, handler) { | ||
var handler = handler || routePath || method; | ||
var routePath = !!handler ? routePath : '/'; | ||
var method = !!routePath ? method.toLowerCase() : 'get'; | ||
@@ -98,3 +98,3 @@ if ('function' === typeof handler && 'GeneratorFunction' === handler.constructor.name) { | ||
if ('function' === typeof handler) { | ||
return handler(router); | ||
return handler.call(this, router); | ||
} | ||
@@ -101,0 +101,0 @@ throw new Error((typeof handler) + ' can not be set as a router'); |
{ | ||
"name": "lark-router", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "An koa route initialization and configuration module.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
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
6329
1