Comparing version 1.1.2 to 1.1.3
@@ -32,3 +32,3 @@ # Koa.js usage: | ||
// now di is already bootstrapped and ready to work. | ||
// In koa app you can right di as `app.context.di` | ||
// In koa app you can reach di as `app.context.di` | ||
// In di you can get koa app as `App` dependency. | ||
@@ -95,2 +95,2 @@ app.use({ | ||
app.listen(3004); | ||
``` | ||
``` |
{ | ||
"name": "hekdi", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Depedency injection framework for node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -10,7 +10,7 @@ /** | ||
/** | ||
* @param ctx {Object} | ||
* @param app {Object} | ||
* @param original {Function} | ||
* @returns {Function} | ||
*/ | ||
const diResolver = function(ctx, original) { | ||
const diResolver = function(app, original) { | ||
/** @param diConfig {Function|String|Object<{controller: string, action: string, [params]: Array}>} */ | ||
@@ -20,8 +20,8 @@ return function(diConfig) { | ||
case 'string': | ||
original.call(ctx, ctx.context.di.resolve(diConfig)); | ||
original.call(app, app.context.di.resolve(diConfig)); | ||
break; | ||
case 'object': // array | ||
case 'object': | ||
const { controller, action, params } = diConfig; | ||
const dependency = ctx.context.di.resolve(controller); | ||
original.call(ctx, async (ctx, next) => { | ||
original.call(app, async (ctx, next) => { | ||
const dependency = app.context.di.resolve(controller); | ||
if (next) { | ||
@@ -35,5 +35,5 @@ await dependency[action](ctx, next, params); | ||
default: // function | ||
original.call(ctx, diConfig); | ||
original.call(app, diConfig); | ||
} | ||
return ctx; | ||
return app; | ||
}; | ||
@@ -58,6 +58,6 @@ }; | ||
break; | ||
case 'object': // array | ||
case 'object': | ||
const { controller, action, params } = diConfig; | ||
const dependency = app.context.di.resolve(controller); | ||
original.call(ctx, path, async (ctx, next) => { | ||
const dependency = app.context.di.resolve(controller); | ||
if (next) { | ||
@@ -64,0 +64,0 @@ await dependency[action](ctx, next, params); |
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
17921