inversify-express-utils
Advanced tools
Comparing version 6.2.0 to 6.3.2
@@ -7,5 +7,4 @@ /// <reference types="express" /> | ||
protected readonly httpContext: interfaces.HttpContext; | ||
private readonly _container; | ||
protected bind<T>(serviceIdentifier: inversifyInterfaces.ServiceIdentifier<T>): inversifyInterfaces.BindingToSyntax<T>; | ||
abstract handler(req: express.Request, res: express.Response, next: express.NextFunction): void; | ||
} |
@@ -49,2 +49,3 @@ /// <reference types="express" /> | ||
response: express.Response; | ||
container: inversifyInterfaces.Container; | ||
user: Principal; | ||
@@ -51,0 +52,0 @@ } |
@@ -12,5 +12,3 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
BaseMiddleware.prototype.bind = function (serviceIdentifier) { | ||
return this._container.isBound(serviceIdentifier) | ||
? this._container.rebind(serviceIdentifier) | ||
: this._container.bind(serviceIdentifier); | ||
return this.httpContext.container.bind(serviceIdentifier); | ||
}; | ||
@@ -17,0 +15,0 @@ BaseMiddleware = __decorate([ |
@@ -175,5 +175,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return function (req, res, next) { | ||
m.httpContext = _self_1._getHttpContext(req); | ||
m._container = _self_1._container; | ||
m.handler(req, res, next); | ||
var mReq = _self_1._container.get(middlewareItem); | ||
mReq.httpContext = _self_1._getHttpContext(req); | ||
mReq.handler(req, res, next); | ||
}; | ||
@@ -216,3 +216,3 @@ } | ||
return function (req, res, next) { return __awaiter(_this, void 0, void 0, function () { | ||
var args, childContainer, httpContext, value, httpResponseMessage, err_1, _a; | ||
var args, httpContext, value, httpResponseMessage, err_1, _a; | ||
return __generator(this, function (_b) { | ||
@@ -223,7 +223,6 @@ switch (_b.label) { | ||
args = this.extractParameters(req, res, next, parameterMetadata); | ||
childContainer = this._container.createChild(); | ||
httpContext = this._getHttpContext(req); | ||
childContainer.bind(TYPE.HttpContext) | ||
httpContext.container.bind(TYPE.HttpContext) | ||
.toConstantValue(httpContext); | ||
return [4 /*yield*/, (_a = childContainer.getNamed(TYPE.Controller, controllerName))[key].apply(_a, args)]; | ||
return [4 /*yield*/, (_a = httpContext.container.getNamed(TYPE.Controller, controllerName))[key].apply(_a, args)]; | ||
case 1: | ||
@@ -280,2 +279,5 @@ value = _b.sent(); | ||
response: res, | ||
// We use a childContainer for each request so we can be | ||
// sure that the binding is unique for each HTTP request | ||
container: this._container.createChild(), | ||
user: principal | ||
@@ -282,0 +284,0 @@ }]; |
@@ -14,5 +14,3 @@ "use strict"; | ||
BaseMiddleware.prototype.bind = function (serviceIdentifier) { | ||
return this._container.isBound(serviceIdentifier) | ||
? this._container.rebind(serviceIdentifier) | ||
: this._container.bind(serviceIdentifier); | ||
return this.httpContext.container.bind(serviceIdentifier); | ||
}; | ||
@@ -19,0 +17,0 @@ BaseMiddleware = __decorate([ |
@@ -177,5 +177,5 @@ "use strict"; | ||
return function (req, res, next) { | ||
m.httpContext = _self_1._getHttpContext(req); | ||
m._container = _self_1._container; | ||
m.handler(req, res, next); | ||
var mReq = _self_1._container.get(middlewareItem); | ||
mReq.httpContext = _self_1._getHttpContext(req); | ||
mReq.handler(req, res, next); | ||
}; | ||
@@ -218,3 +218,3 @@ } | ||
return function (req, res, next) { return __awaiter(_this, void 0, void 0, function () { | ||
var args, childContainer, httpContext, value, httpResponseMessage, err_1, _a; | ||
var args, httpContext, value, httpResponseMessage, err_1, _a; | ||
return __generator(this, function (_b) { | ||
@@ -225,7 +225,6 @@ switch (_b.label) { | ||
args = this.extractParameters(req, res, next, parameterMetadata); | ||
childContainer = this._container.createChild(); | ||
httpContext = this._getHttpContext(req); | ||
childContainer.bind(constants_1.TYPE.HttpContext) | ||
httpContext.container.bind(constants_1.TYPE.HttpContext) | ||
.toConstantValue(httpContext); | ||
return [4 /*yield*/, (_a = childContainer.getNamed(constants_1.TYPE.Controller, controllerName))[key].apply(_a, args)]; | ||
return [4 /*yield*/, (_a = httpContext.container.getNamed(constants_1.TYPE.Controller, controllerName))[key].apply(_a, args)]; | ||
case 1: | ||
@@ -282,2 +281,5 @@ value = _b.sent(); | ||
response: res, | ||
// We use a childContainer for each request so we can be | ||
// sure that the binding is unique for each HTTP request | ||
container: this._container.createChild(), | ||
user: principal | ||
@@ -284,0 +286,0 @@ }]; |
{ | ||
"name": "inversify-express-utils", | ||
"version": "6.2.0", | ||
"version": "6.3.2", | ||
"description": "Some utilities for the development of express applications with Inversify", | ||
@@ -28,4 +28,4 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@types/async": "2.0.49", | ||
"@types/bluebird": "3.5.24", | ||
"@types/async": "2.0.50", | ||
"@types/bluebird": "3.5.25", | ||
"@types/body-parser": "1.17.0", | ||
@@ -37,6 +37,6 @@ "@types/chai": "4.1.4", | ||
"@types/prettyjson": "0.0.28", | ||
"@types/sinon": "5.0.5", | ||
"@types/supertest": "2.0.6", | ||
"@types/sinon": "7.0.1", | ||
"@types/supertest": "2.0.7", | ||
"async": "2.6.1", | ||
"bluebird": "3.5.1", | ||
"bluebird": "3.5.3", | ||
"body-parser": "1.18.3", | ||
@@ -50,8 +50,8 @@ "chai": "4.1.2", | ||
"gulp-tslint": "8.1.3", | ||
"gulp-typescript": "4.0.2", | ||
"inversify": "4.13.0", | ||
"gulp-typescript": "5.0.0", | ||
"inversify": "5.0.1", | ||
"mocha": "5.2.0", | ||
"moq.ts": "^2.6.0", | ||
"moq.ts": "^2.7.3", | ||
"prettyjson": "1.2.1", | ||
"publish-please": "4.0.1", | ||
"publish-please": "5.4.3", | ||
"reflect-metadata": "0.1.12", | ||
@@ -61,3 +61,3 @@ "run-sequence": "2.2.1", | ||
"source-map-support": "0.5.6", | ||
"supertest": "3.1.0", | ||
"supertest": "3.3.0", | ||
"tslint": "5.9.1", | ||
@@ -64,0 +64,0 @@ "typescript": "^2.8.3" |
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
221719
89
22