Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

inversify-express-utils

Package Overview
Dependencies
Maintainers
3
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inversify-express-utils - npm Package Compare versions

Comparing version 6.4.5 to 6.4.6

.eslintrc.js

1

es/base_http_controller.js

@@ -62,1 +62,2 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

export { BaseHttpController };
//# sourceMappingURL=base_http_controller.js.map

@@ -20,1 +20,2 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

export { BaseMiddleware };
//# sourceMappingURL=base_middleware.js.map

7

es/constants.js

@@ -38,6 +38,5 @@ export var TYPE = {

})(HTTP_VERBS_ENUM || (HTTP_VERBS_ENUM = {}));
export var DUPLICATED_CONTROLLER_NAME = function (name) { return "Two controllers cannot have the same name: ".concat(name); };
export var NO_CONTROLLERS_FOUND = 'No controllers' +
'have been found! Please ensure that you have register' +
'at least one Controller.';
export var DUPLICATED_CONTROLLER_NAME = function (name) { return "Two controllers cannot have the same name: " + name; };
export var NO_CONTROLLERS_FOUND = 'No controllers have been found! Please ensure that you have register at least one Controller.';
export var DEFAULT_ROUTING_ROOT_PATH = '/';
//# sourceMappingURL=constants.js.map

@@ -15,1 +15,2 @@ var HttpContent = (function () {

export { HttpContent };
//# sourceMappingURL=httpContent.js.map

@@ -22,7 +22,7 @@ var __extends = (this && this.__extends) || (function () {

var _this = _super.call(this) || this;
_this.content = content;
_this.content = JSON.stringify(content);
_this.headers['content-type'] = DEFAULT_MEDIA_TYPE;
return _this;
}
JsonContent.prototype.readAsync = function () {
JsonContent.prototype.readAsStringAsync = function () {
return Promise.resolve(this.content);

@@ -33,1 +33,2 @@ };

export { JsonContent };
//# sourceMappingURL=jsonContent.js.map

@@ -26,3 +26,3 @@ var __extends = (this && this.__extends) || (function () {

}
StringContent.prototype.readAsync = function () {
StringContent.prototype.readAsStringAsync = function () {
return Promise.resolve(this.content);

@@ -33,1 +33,2 @@ };

export { StringContent };
//# sourceMappingURL=stringContent.js.map

@@ -49,3 +49,3 @@ import { PARAMETER_TYPE } from './constants';

}
return "".concat(type, " ").concat(a.parameterName);
return type + " " + a.parameterName;
});

@@ -55,3 +55,3 @@ }

var details = {
route: "".concat(method, " ").concat(controllerPath).concat(actionPath),
route: method + " " + controllerPath + actionPath,
};

@@ -80,1 +80,2 @@ if (args) {

}
//# sourceMappingURL=debug.js.map

@@ -113,5 +113,3 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {

function paramDecoratorFactory(parameterType) {
return function (name) {
return params(parameterType, name);
};
return function (name) { return params(parameterType, name); };
}

@@ -142,1 +140,2 @@ export function params(type, parameterName) {

}
//# sourceMappingURL=decorators.js.map

@@ -33,3 +33,3 @@ var HttpResponseMessage = (function () {

if (code < 0 || code > 999) {
throw new Error("".concat(code, " is not a valid status code"));
throw new Error(code + " is not a valid status code");
}

@@ -44,1 +44,2 @@ this._statusCode = code;

export { HttpResponseMessage };
//# sourceMappingURL=httpResponseMessage.js.map

@@ -17,1 +17,2 @@ export * from './server';

export * from './content/httpContent';
//# sourceMappingURL=index.js.map
export {};
//# sourceMappingURL=interfaces.js.map

@@ -50,3 +50,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

response.content = new StringContent(this.message);
return [2, Promise.resolve(response)];
return [2, response];
});

@@ -58,1 +58,2 @@ });

export { BadRequestErrorMessageResult };
//# sourceMappingURL=BadRequestErrorMessageResult.js.map

@@ -45,3 +45,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

return __generator(this, function (_a) {
return [2, Promise.resolve(new HttpResponseMessage(StatusCodes.BAD_REQUEST))];
return [2, new HttpResponseMessage(StatusCodes.BAD_REQUEST)];
});

@@ -53,1 +53,2 @@ });

export { BadRequestResult };
//# sourceMappingURL=BadRequestResult.js.map

@@ -45,3 +45,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

return __generator(this, function (_a) {
return [2, Promise.resolve(new HttpResponseMessage(StatusCodes.CONFLICT))];
return [2, new HttpResponseMessage(StatusCodes.CONFLICT)];
});

@@ -53,1 +53,2 @@ });

export { ConflictResult };
//# sourceMappingURL=ConflictResult.js.map

@@ -52,3 +52,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

response.headers['location'] = this.location.toString();
return [2, Promise.resolve(response)];
return [2, response];
});

@@ -60,1 +60,2 @@ });

export { CreatedNegotiatedContentResult };
//# sourceMappingURL=CreatedNegotiatedContentResult.js.map

@@ -50,3 +50,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

response.content = new StringContent(this.error.toString());
return [2, Promise.resolve(response)];
return [2, response];
});

@@ -58,1 +58,2 @@ });

export { ExceptionResult };
//# sourceMappingURL=ExceptionResult.js.map

@@ -14,1 +14,2 @@ export * from './ExceptionResult';

export * from './JsonResult';
//# sourceMappingURL=index.js.map

@@ -45,3 +45,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

return __generator(this, function (_a) {
return [2, Promise.resolve(new HttpResponseMessage(StatusCodes.INTERNAL_SERVER_ERROR))];
return [2, new HttpResponseMessage(StatusCodes.INTERNAL_SERVER_ERROR)];
});

@@ -53,1 +53,2 @@ });

export { InternalServerErrorResult };
//# sourceMappingURL=InternalServerError.js.map

@@ -37,4 +37,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
import { HttpResponseMessage } from '../httpResponseMessage';
import { JsonContent } from '../content/jsonContent';
import { HttpResponseMessage } from '../httpResponseMessage';
var JsonResult = (function () {

@@ -51,3 +51,3 @@ function JsonResult(json, statusCode) {

response.content = new JsonContent(this.json);
return [2, Promise.resolve(response)];
return [2, response];
});

@@ -59,1 +59,2 @@ });

export { JsonResult };
//# sourceMappingURL=JsonResult.js.map

@@ -45,3 +45,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

return __generator(this, function (_a) {
return [2, Promise.resolve(new HttpResponseMessage(StatusCodes.NOT_FOUND))];
return [2, new HttpResponseMessage(StatusCodes.NOT_FOUND)];
});

@@ -53,1 +53,2 @@ });

export { NotFoundResult };
//# sourceMappingURL=NotFoundResult.js.map

@@ -50,3 +50,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

response.content = new StringContent(JSON.stringify(this.content));
return [2, Promise.resolve(response)];
return [2, response];
});

@@ -58,1 +58,2 @@ });

export { OkNegotiatedContentResult };
//# sourceMappingURL=OkNegotiatedContentResult.js.map

@@ -45,3 +45,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

return __generator(this, function (_a) {
return [2, Promise.resolve(new HttpResponseMessage(StatusCodes.OK))];
return [2, new HttpResponseMessage(StatusCodes.OK)];
});

@@ -53,1 +53,2 @@ });

export { OkResult };
//# sourceMappingURL=OkResult.js.map

@@ -49,3 +49,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

response.headers['location'] = this.location.toString();
return [2, Promise.resolve(response)];
return [2, response];
});

@@ -57,1 +57,2 @@ });

export { RedirectResult };
//# sourceMappingURL=RedirectResult.js.map

@@ -44,3 +44,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

return __generator(this, function (_a) {
return [2, Promise.resolve(this.message)];
return [2, this.message];
});

@@ -52,1 +52,2 @@ });

export { ResponseMessageResult };
//# sourceMappingURL=ResponseMessageResult.js.map

@@ -45,3 +45,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

return __generator(this, function (_a) {
return [2, Promise.resolve(new HttpResponseMessage(this.statusCode))];
return [2, new HttpResponseMessage(this.statusCode)];
});

@@ -53,1 +53,2 @@ });

export { StatusCodeResult };
//# sourceMappingURL=StatusCodeResult.js.map

@@ -46,5 +46,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
import express, { Router } from 'express';
import * as express from 'express';
import { BaseMiddleware } from './index';
import { getControllersFromMetadata, getControllersFromContainer, getControllerMetadata, getControllerMethodMetadata, getControllerParameterMetadata, instanceOfIHttpActionResult } from './utils';
import { getControllersFromMetadata, getControllersFromContainer, getControllerMetadata, getControllerMethodMetadata, getControllerParameterMetadata, instanceOfIHttpActionResult, } from './utils';
import { TYPE, METADATA_KEY, DEFAULT_ROUTING_ROOT_PATH, PARAMETER_TYPE, DUPLICATED_CONTROLLER_NAME, } from './constants';

@@ -57,3 +57,3 @@ import { HttpResponseMessage } from './httpResponseMessage';

this._forceControllers = forceControllers;
this._router = customRouter || Router();
this._router = customRouter || express.Router();
this._routingConfig = routingConfig || {

@@ -80,3 +80,3 @@ rootPath: DEFAULT_ROUTING_ROOT_PATH,

this._app.all('*', function (req, res, next) {
void (function () { return __awaiter(_this, void 0, void 0, function () {
(function () { return __awaiter(_this, void 0, void 0, function () {
var httpContext;

@@ -106,5 +106,3 @@ return __generator(this, function (_a) {

var _this = this;
this._container
.bind(TYPE.HttpContext)
.toConstantValue({});
this._container.bind(TYPE.HttpContext).toConstantValue({});
var constructors = getControllersFromMetadata();

@@ -135,3 +133,3 @@ constructors.forEach(function (constructor) {

var routeMiddleware = _this.resolveMidleware.apply(_this, metadata.middleware);
(_a = _this._router)[metadata.method].apply(_a, __spreadArray(__spreadArray(__spreadArray(["".concat(controllerMetadata.path).concat(metadata.path)], controllerMiddleware_1, false), routeMiddleware, false), [handler], false));
(_a = _this._router)[metadata.method].apply(_a, __spreadArray(__spreadArray(__spreadArray(["" + controllerMetadata.path + metadata.path], controllerMiddleware_1, false), routeMiddleware, false), [handler], false));
});

@@ -152,12 +150,11 @@ }

}
var middlewareInstance = _this._container
.get(middlewareItem);
if (middlewareInstance instanceof BaseMiddleware) {
var m = _this._container.get(middlewareItem);
if (m instanceof BaseMiddleware) {
return function (req, res, next) {
var mReq = _this._container.get(middlewareItem);
mReq.httpContext = _this._getHttpContext(req);
(mReq).httpContext = _this._getHttpContext(req);
mReq.handler(req, res, next);
};
}
return middlewareInstance;
return m;
});

@@ -183,3 +180,3 @@ };

.send;
return [4, message.content.readAsync()];
return [4, message.content.readAsStringAsync()];
case 1:

@@ -259,6 +256,6 @@ _b.apply(_a, [_c.sent()]);

return [2, {
container: this._container.createChild(),
request: req,
response: res,
user: principal
container: this._container.createChild(),
user: principal,
}];

@@ -280,4 +277,4 @@ }

isAuthenticated: function () { return Promise.resolve(false); },
isInRole: function (_role) { return Promise.resolve(false); },
isResourceOwner: function (_resourceId) { return Promise.resolve(false); },
isInRole: function (role) { return Promise.resolve(false); },
isResourceOwner: function (resourceId) { return Promise.resolve(false); },
})];

@@ -342,1 +339,2 @@ });

export { InversifyExpressServer };
//# sourceMappingURL=server.js.map

@@ -58,4 +58,4 @@ var __assign = (this && this.__assign) || function () {

export function instanceOfIHttpActionResult(value) {
return value != null &&
typeof value.executeAsync === 'function';
return value != null && typeof value.executeAsync === 'function';
}
//# sourceMappingURL=utils.js.map

@@ -61,1 +61,2 @@ "use strict";

exports.BaseHttpController = BaseHttpController;
//# sourceMappingURL=base_http_controller.js.map

@@ -20,1 +20,2 @@ "use strict";

exports.BaseMiddleware = BaseMiddleware;
//# sourceMappingURL=base_middleware.js.map

@@ -43,5 +43,4 @@ "use strict";

exports.DUPLICATED_CONTROLLER_NAME = DUPLICATED_CONTROLLER_NAME;
exports.NO_CONTROLLERS_FOUND = 'No controllers' +
'have been found! Please ensure that you have register' +
'at least one Controller.';
exports.NO_CONTROLLERS_FOUND = 'No controllers have been found! Please ensure that you have register at least one Controller.';
exports.DEFAULT_ROUTING_ROOT_PATH = '/';
//# sourceMappingURL=constants.js.map

@@ -13,1 +13,2 @@ "use strict";

exports.HttpContent = HttpContent;
//# sourceMappingURL=httpContent.js.map

@@ -9,6 +9,6 @@ "use strict";

super();
this.content = content;
this.content = JSON.stringify(content);
this.headers['content-type'] = DEFAULT_MEDIA_TYPE;
}
readAsync() {
readAsStringAsync() {
return Promise.resolve(this.content);

@@ -18,1 +18,2 @@ }

exports.JsonContent = JsonContent;
//# sourceMappingURL=jsonContent.js.map

@@ -12,3 +12,3 @@ "use strict";

}
readAsync() {
readAsStringAsync() {
return Promise.resolve(this.content);

@@ -18,1 +18,2 @@ }

exports.StringContent = StringContent;
//# sourceMappingURL=stringContent.js.map

@@ -83,1 +83,2 @@ "use strict";

exports.getRawMetadata = getRawMetadata;
//# sourceMappingURL=debug.js.map

@@ -107,1 +107,2 @@ "use strict";

exports.params = params;
//# sourceMappingURL=decorators.js.map

@@ -32,1 +32,2 @@ "use strict";

exports.HttpResponseMessage = HttpResponseMessage;
//# sourceMappingURL=httpResponseMessage.js.map

@@ -9,17 +9,5 @@ "use strict";

}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -31,4 +19,4 @@ exports.results = exports.interfaces = void 0;

__exportStar(require("./interfaces"), exports);
exports.interfaces = __importStar(require("./interfaces"));
exports.results = __importStar(require("./results"));
exports.interfaces = require("./interfaces");
exports.results = require("./results");
__exportStar(require("./base_http_controller"), exports);

@@ -42,1 +30,2 @@ __exportStar(require("./base_middleware"), exports);

__exportStar(require("./content/httpContent"), exports);
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interfaces.js.map

@@ -24,3 +24,3 @@ "use strict";

response.content = new stringContent_1.StringContent(this.message);
return Promise.resolve(response);
return response;
});

@@ -30,1 +30,2 @@ }

exports.BadRequestErrorMessageResult = BadRequestErrorMessageResult;
//# sourceMappingURL=BadRequestErrorMessageResult.js.map

@@ -18,3 +18,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.BAD_REQUEST));
return new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.BAD_REQUEST);
});

@@ -24,1 +24,2 @@ }

exports.BadRequestResult = BadRequestResult;
//# sourceMappingURL=BadRequestResult.js.map

@@ -18,3 +18,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.CONFLICT));
return new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.CONFLICT);
});

@@ -24,1 +24,2 @@ }

exports.ConflictResult = ConflictResult;
//# sourceMappingURL=ConflictResult.js.map

@@ -26,3 +26,3 @@ "use strict";

response.headers['location'] = this.location.toString();
return Promise.resolve(response);
return response;
});

@@ -32,1 +32,2 @@ }

exports.CreatedNegotiatedContentResult = CreatedNegotiatedContentResult;
//# sourceMappingURL=CreatedNegotiatedContentResult.js.map

@@ -24,3 +24,3 @@ "use strict";

response.content = new stringContent_1.StringContent(this.error.toString());
return Promise.resolve(response);
return response;
});

@@ -30,1 +30,2 @@ }

exports.ExceptionResult = ExceptionResult;
//# sourceMappingURL=ExceptionResult.js.map

@@ -26,1 +26,2 @@ "use strict";

__exportStar(require("./JsonResult"), exports);
//# sourceMappingURL=index.js.map

@@ -18,3 +18,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR));
return new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR);
});

@@ -24,1 +24,2 @@ }

exports.InternalServerErrorResult = InternalServerErrorResult;
//# sourceMappingURL=InternalServerError.js.map

@@ -13,4 +13,4 @@ "use strict";

exports.JsonResult = void 0;
const httpResponseMessage_1 = require("../httpResponseMessage");
const jsonContent_1 = require("../content/jsonContent");
const httpResponseMessage_1 = require("../httpResponseMessage");
class JsonResult {

@@ -25,3 +25,3 @@ constructor(json, statusCode) {

response.content = new jsonContent_1.JsonContent(this.json);
return Promise.resolve(response);
return response;
});

@@ -31,1 +31,2 @@ }

exports.JsonResult = JsonResult;
//# sourceMappingURL=JsonResult.js.map

@@ -18,3 +18,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.NOT_FOUND));
return new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.NOT_FOUND);
});

@@ -24,1 +24,2 @@ }

exports.NotFoundResult = NotFoundResult;
//# sourceMappingURL=NotFoundResult.js.map

@@ -24,3 +24,3 @@ "use strict";

response.content = new stringContent_1.StringContent(JSON.stringify(this.content));
return Promise.resolve(response);
return response;
});

@@ -30,1 +30,2 @@ }

exports.OkNegotiatedContentResult = OkNegotiatedContentResult;
//# sourceMappingURL=OkNegotiatedContentResult.js.map

@@ -18,3 +18,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.OK));
return new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.OK);
});

@@ -24,1 +24,2 @@ }

exports.OkResult = OkResult;
//# sourceMappingURL=OkResult.js.map

@@ -23,3 +23,3 @@ "use strict";

response.headers['location'] = this.location.toString();
return Promise.resolve(response);
return response;
});

@@ -29,1 +29,2 @@ }

exports.RedirectResult = RedirectResult;
//# sourceMappingURL=RedirectResult.js.map

@@ -19,3 +19,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(this.message);
return this.message;
});

@@ -25,1 +25,2 @@ }

exports.ResponseMessageResult = ResponseMessageResult;
//# sourceMappingURL=ResponseMessageResult.js.map

@@ -20,3 +20,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
return Promise.resolve(new httpResponseMessage_1.HttpResponseMessage(this.statusCode));
return new httpResponseMessage_1.HttpResponseMessage(this.statusCode);
});

@@ -26,1 +26,2 @@ }

exports.StatusCodeResult = StatusCodeResult;
//# sourceMappingURL=StatusCodeResult.js.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -32,3 +13,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

exports.InversifyExpressServer = void 0;
const express_1 = __importStar(require("express"));
const express = require("express");
const index_1 = require("./index");

@@ -42,7 +23,7 @@ const utils_1 = require("./utils");

this._forceControllers = forceControllers;
this._router = customRouter || (0, express_1.Router)();
this._router = customRouter || express.Router();
this._routingConfig = routingConfig || {
rootPath: constants_1.DEFAULT_ROUTING_ROOT_PATH,
};
this._app = customApp || (0, express_1.default)();
this._app = customApp || express();
if (authProvider) {

@@ -64,3 +45,3 @@ this._AuthProvider = authProvider;

this._app.all('*', (req, res, next) => {
void (() => __awaiter(this, void 0, void 0, function* () {
(() => __awaiter(this, void 0, void 0, function* () {
const httpContext = yield this._createHttpContext(req, res, next);

@@ -81,5 +62,3 @@ Reflect.defineMetadata(constants_1.METADATA_KEY.httpContext, httpContext, req);

registerControllers() {
this._container
.bind(constants_1.TYPE.HttpContext)
.toConstantValue({});
this._container.bind(constants_1.TYPE.HttpContext).toConstantValue({});
const constructors = (0, utils_1.getControllersFromMetadata)();

@@ -120,12 +99,11 @@ constructors.forEach(constructor => {

}
const middlewareInstance = this._container
.get(middlewareItem);
if (middlewareInstance instanceof index_1.BaseMiddleware) {
const m = this._container.get(middlewareItem);
if (m instanceof index_1.BaseMiddleware) {
return (req, res, next) => {
const mReq = this._container.get(middlewareItem);
mReq.httpContext = this._getHttpContext(req);
(mReq).httpContext = this._getHttpContext(req);
mReq.handler(req, res, next);
};
}
return middlewareInstance;
return m;
});

@@ -145,3 +123,3 @@ }

res.status(message.statusCode)
.send(yield message.content.readAsync());
.send(yield message.content.readAsStringAsync());
}

@@ -190,6 +168,6 @@ else {

return {
container: this._container.createChild(),
request: req,
response: res,
user: principal
container: this._container.createChild(),
user: principal,
};

@@ -207,4 +185,4 @@ });

isAuthenticated: () => Promise.resolve(false),
isInRole: (_role) => Promise.resolve(false),
isResourceOwner: (_resourceId) => Promise.resolve(false),
isInRole: (role) => Promise.resolve(false),
isResourceOwner: (resourceId) => Promise.resolve(false),
});

@@ -265,1 +243,2 @@ });

exports.InversifyExpressServer = InversifyExpressServer;
//# sourceMappingURL=server.js.map

@@ -56,5 +56,5 @@ "use strict";

function instanceOfIHttpActionResult(value) {
return value != null &&
typeof value.executeAsync === 'function';
return value != null && typeof value.executeAsync === 'function';
}
exports.instanceOfIHttpActionResult = instanceOfIHttpActionResult;
//# sourceMappingURL=utils.js.map

@@ -5,3 +5,3 @@ /// <reference types="node" />

import { CreatedNegotiatedContentResult, ConflictResult, OkNegotiatedContentResult, OkResult, BadRequestErrorMessageResult, BadRequestResult, ExceptionResult, InternalServerErrorResult, NotFoundResult, RedirectResult, ResponseMessageResult, StatusCodeResult, JsonResult } from './results';
import type { HttpContext } from './interfaces';
import { HttpContext } from './interfaces';
export declare class BaseHttpController {

@@ -21,3 +21,3 @@ protected readonly httpContext: HttpContext;

protected statusCode(statusCode: number): StatusCodeResult;
protected json<T extends Record<string, unknown>>(content: T | T[], statusCode?: number): JsonResult<T>;
protected json(content: any, statusCode?: number): JsonResult;
}

@@ -65,1 +65,2 @@ "use strict";

exports.BaseHttpController = BaseHttpController;
//# sourceMappingURL=base_http_controller.js.map

@@ -1,8 +0,8 @@

import type { NextFunction, Request, Response } from 'express';
import * as express from 'express';
import { interfaces as inversifyInterfaces } from 'inversify';
import type { HttpContext } from './interfaces';
import * as interfaces from './interfaces';
export declare abstract class BaseMiddleware implements BaseMiddleware {
httpContext: HttpContext;
httpContext: interfaces.HttpContext;
protected bind<T>(serviceIdentifier: inversifyInterfaces.ServiceIdentifier<T>): inversifyInterfaces.BindingToSyntax<T>;
abstract handler(req: Request, res: Response, next: NextFunction): void;
abstract handler(req: express.Request, res: express.Response, next: express.NextFunction): void;
}

@@ -23,1 +23,2 @@ "use strict";

exports.BaseMiddleware = BaseMiddleware;
//# sourceMappingURL=base_middleware.js.map

@@ -37,3 +37,3 @@ export declare const TYPE: {

export declare const DUPLICATED_CONTROLLER_NAME: (name: string) => string;
export declare const NO_CONTROLLERS_FOUND: string;
export declare const NO_CONTROLLERS_FOUND = "No controllers have been found! Please ensure that you have register at least one Controller.";
export declare const DEFAULT_ROUTING_ROOT_PATH = "/";

@@ -41,7 +41,6 @@ "use strict";

})(HTTP_VERBS_ENUM = exports.HTTP_VERBS_ENUM || (exports.HTTP_VERBS_ENUM = {}));
var DUPLICATED_CONTROLLER_NAME = function (name) { return "Two controllers cannot have the same name: ".concat(name); };
var DUPLICATED_CONTROLLER_NAME = function (name) { return "Two controllers cannot have the same name: " + name; };
exports.DUPLICATED_CONTROLLER_NAME = DUPLICATED_CONTROLLER_NAME;
exports.NO_CONTROLLERS_FOUND = 'No controllers' +
'have been found! Please ensure that you have register' +
'at least one Controller.';
exports.NO_CONTROLLERS_FOUND = 'No controllers have been found! Please ensure that you have register at least one Controller.';
exports.DEFAULT_ROUTING_ROOT_PATH = '/';
//# sourceMappingURL=constants.js.map
/// <reference types="node" />
import type { OutgoingHttpHeaders } from 'node:http';
import { OutgoingHttpHeaders } from 'http';
export declare abstract class HttpContent {
private _headers;
get headers(): OutgoingHttpHeaders;
abstract readAsync(): Promise<string | Record<string, unknown> | Record<string, unknown>[]>;
abstract readAsStringAsync(): Promise<string>;
}

@@ -18,1 +18,2 @@ "use strict";

exports.HttpContent = HttpContent;
//# sourceMappingURL=httpContent.js.map
import { HttpContent } from './httpContent';
export declare class JsonContent<T extends Record<string, unknown>> extends HttpContent {
export declare class JsonContent extends HttpContent {
private content;
constructor(content: T | T[]);
readAsync(): Promise<T | T[]>;
constructor(content: any);
readAsStringAsync(): Promise<string>;
}

@@ -25,7 +25,7 @@ "use strict";

var _this = _super.call(this) || this;
_this.content = content;
_this.content = JSON.stringify(content);
_this.headers['content-type'] = DEFAULT_MEDIA_TYPE;
return _this;
}
JsonContent.prototype.readAsync = function () {
JsonContent.prototype.readAsStringAsync = function () {
return Promise.resolve(this.content);

@@ -36,1 +36,2 @@ };

exports.JsonContent = JsonContent;
//# sourceMappingURL=jsonContent.js.map

@@ -5,3 +5,3 @@ import { HttpContent } from './httpContent';

constructor(content: string);
readAsync(): Promise<string>;
readAsStringAsync(): Promise<string>;
}

@@ -29,3 +29,3 @@ "use strict";

}
StringContent.prototype.readAsync = function () {
StringContent.prototype.readAsStringAsync = function () {
return Promise.resolve(this.content);

@@ -36,1 +36,2 @@ };

exports.StringContent = StringContent;
//# sourceMappingURL=stringContent.js.map
import { interfaces as inversifyInterfaces } from 'inversify';
import type { RouteInfo, RawMetadata } from './interfaces';
import { RouteInfo, RawMetadata } from './interfaces';
export declare function getRouteInfo(container: inversifyInterfaces.Container): Array<RouteInfo>;
export declare function getRawMetadata(container: inversifyInterfaces.Container): Array<RawMetadata>;

@@ -52,3 +52,3 @@ "use strict";

}
return "".concat(type, " ").concat(a.parameterName);
return type + " " + a.parameterName;
});

@@ -58,3 +58,3 @@ }

var details = {
route: "".concat(method, " ").concat(controllerPath).concat(actionPath),
route: method + " " + controllerPath + actionPath,
};

@@ -85,1 +85,2 @@ if (args) {

exports.getRawMetadata = getRawMetadata;
//# sourceMappingURL=debug.js.map

@@ -0,5 +1,5 @@

import { Controller, Middleware, HandlerDecorator } from './interfaces';
import { PARAMETER_TYPE, HTTP_VERBS_ENUM } from './constants';
import type { Controller, Middleware, HandlerDecorator } from './interfaces';
export declare const injectHttpContext: (target: import("inversify/lib/annotation/decorator_utils").DecoratorTarget<unknown>, targetKey?: string | symbol | undefined, indexOrPropertyDescriptor?: number | TypedPropertyDescriptor<any> | undefined) => void;
export declare function controller(path: string, ...middleware: Array<Middleware>): (target: NewableFunction) => void;
export declare function controller(path: string, ...middleware: Array<Middleware>): (target: any) => void;
export declare function all(path: string, ...middleware: Array<Middleware>): HandlerDecorator;

@@ -22,2 +22,2 @@ export declare function httpGet(path: string, ...middleware: Array<Middleware>): HandlerDecorator;

export declare const principal: () => ParameterDecorator;
export declare function params(type: PARAMETER_TYPE, parameterName?: string): (target: unknown | Controller, methodName: string | symbol, index: number) => void;
export declare function params(type: PARAMETER_TYPE, parameterName?: string): (target: Controller, methodName: string | symbol, index: number) => void;

@@ -125,5 +125,3 @@ "use strict";

function paramDecoratorFactory(parameterType) {
return function (name) {
return params(parameterType, name);
};
return function (name) { return params(parameterType, name); };
}

@@ -155,1 +153,2 @@ function params(type, parameterName) {

exports.params = params;
//# sourceMappingURL=decorators.js.map
/// <reference types="node" />
import type { OutgoingHttpHeaders } from 'node:http';
import { OutgoingHttpHeaders } from 'http';
import { HttpContent } from './content/httpContent';

@@ -4,0 +4,0 @@ export declare class HttpResponseMessage {

@@ -36,3 +36,3 @@ "use strict";

if (code < 0 || code > 999) {
throw new Error("".concat(code, " is not a valid status code"));
throw new Error(code + " is not a valid status code");
}

@@ -47,1 +47,2 @@ this._statusCode = code;

exports.HttpResponseMessage = HttpResponseMessage;
//# sourceMappingURL=httpResponseMessage.js.map

@@ -0,0 +0,0 @@ export * from './server';

@@ -9,17 +9,5 @@ "use strict";

}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -31,4 +19,4 @@ exports.results = exports.interfaces = void 0;

__exportStar(require("./interfaces"), exports);
exports.interfaces = __importStar(require("./interfaces"));
exports.results = __importStar(require("./results"));
exports.interfaces = require("./interfaces");
exports.results = require("./results");
__exportStar(require("./base_http_controller"), exports);

@@ -42,1 +30,2 @@ __exportStar(require("./base_middleware"), exports);

__exportStar(require("./content/httpContent"), exports);
//# sourceMappingURL=index.js.map

@@ -1,26 +0,14 @@

import type { Application, NextFunction, Request, RequestHandler, Response } from 'express';
import * as express from 'express';
import { interfaces as inversifyInterfaces } from 'inversify';
import { HTTP_VERBS_ENUM, PARAMETER_TYPE } from './constants';
import { HttpResponseMessage } from './httpResponseMessage';
declare type Prototype<T> = {
[P in keyof T]: T[P] extends NewableFunction ? T[P] : T[P] | undefined;
} & {
constructor: NewableFunction;
};
interface ConstructorFunction<T = Record<string, unknown>> {
new (...args: Array<unknown>): T;
prototype: Prototype<T>;
}
export declare type DecoratorTarget<T = unknown> = ConstructorFunction<T> | Prototype<T>;
export declare type Middleware = (string | symbol | RequestHandler);
export declare type ControllerHandler = (...params: Array<unknown>) => unknown;
export declare type Controller = Record<string, ControllerHandler>;
export declare type Middleware = (inversifyInterfaces.ServiceIdentifier<any> | express.RequestHandler);
export interface ControllerMetadata {
path: string;
middleware: Array<Middleware>;
path: string;
target: DecoratorTarget;
target: any;
}
export interface ControllerMethodMetadata extends ControllerMetadata {
method: keyof typeof HTTP_VERBS_ENUM;
key: string;
method: keyof typeof HTTP_VERBS_ENUM;
}

@@ -31,27 +19,28 @@ export interface ControllerParameterMetadata {

export interface ParameterMetadata {
parameterName?: string;
injectRoot: boolean;
index: number;
injectRoot: boolean;
parameterName?: string | undefined;
type: PARAMETER_TYPE;
}
export declare type ExtractedParameters = Array<ParameterMetadata> | [Request, Response, NextFunction] | Array<unknown>;
export declare type HandlerDecorator = (target: DecoratorTarget, key: string, value: unknown) => void;
export declare type ConfigFunction = (app: Application) => void;
export interface Controller {
}
export declare type HandlerDecorator = (target: any, key: string, value: any) => void;
export declare type ConfigFunction = (app: express.Application) => void;
export interface RoutingConfig {
rootPath: string;
}
export interface Principal<T = unknown> {
details: T;
export interface Principal {
details: any;
isAuthenticated(): Promise<boolean>;
isResourceOwner(resourceId: any): Promise<boolean>;
isInRole(role: string): Promise<boolean>;
isResourceOwner(resourceId: unknown): Promise<boolean>;
}
export interface AuthProvider {
getUser(req: Request, res: Response, next: NextFunction): Promise<Principal>;
getUser(req: express.Request, res: express.Response, next: express.NextFunction): Promise<Principal>;
}
export interface HttpContext<T = unknown> {
export interface HttpContext {
request: express.Request;
response: express.Response;
container: inversifyInterfaces.Container;
request: Request;
response: Response;
user: Principal<T>;
user: Principal;
}

@@ -62,7 +51,7 @@ export interface IHttpActionResult {

export interface RouteDetails {
route: string;
args?: Array<string>;
route: string;
}
export interface RouteInfo {
controller: string;
controller: any;
endpoints: Array<RouteDetails>;

@@ -75,2 +64,1 @@ }

}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interfaces.js.map
import { HttpResponseMessage } from '../httpResponseMessage';
import type { IHttpActionResult } from '../interfaces';
import { IHttpActionResult } from '../interfaces';
export declare class BadRequestErrorMessageResult implements IHttpActionResult {

@@ -4,0 +4,0 @@ private message;

@@ -53,3 +53,3 @@ "use strict";

response.content = new stringContent_1.StringContent(this.message);
return [2, Promise.resolve(response)];
return [2, response];
});

@@ -61,1 +61,2 @@ });

exports.BadRequestErrorMessageResult = BadRequestErrorMessageResult;
//# sourceMappingURL=BadRequestErrorMessageResult.js.map
import { HttpResponseMessage } from '../httpResponseMessage';
import type { IHttpActionResult } from '../interfaces';
import { IHttpActionResult } from '../interfaces';
export declare class BadRequestResult implements IHttpActionResult {
executeAsync(): Promise<HttpResponseMessage>;
}

@@ -48,3 +48,3 @@ "use strict";

return __generator(this, function (_a) {
return [2, Promise.resolve(new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.BAD_REQUEST))];
return [2, new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.BAD_REQUEST)];
});

@@ -56,1 +56,2 @@ });

exports.BadRequestResult = BadRequestResult;
//# sourceMappingURL=BadRequestResult.js.map
import { HttpResponseMessage } from '../httpResponseMessage';
import type { IHttpActionResult } from '../interfaces';
import { IHttpActionResult } from '../interfaces';
export declare class ConflictResult implements IHttpActionResult {
executeAsync(): Promise<HttpResponseMessage>;
}

@@ -48,3 +48,3 @@ "use strict";

return __generator(this, function (_a) {
return [2, Promise.resolve(new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.CONFLICT))];
return [2, new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.CONFLICT)];
});

@@ -56,1 +56,2 @@ });

exports.ConflictResult = ConflictResult;
//# sourceMappingURL=ConflictResult.js.map
/// <reference types="node" />
import { URL } from 'node:url';
import { URL } from 'url';
import { HttpResponseMessage } from '../httpResponseMessage';
import type { IHttpActionResult } from '../interfaces';
import { IHttpActionResult } from '../interfaces';
export declare class CreatedNegotiatedContentResult<T> implements IHttpActionResult {

@@ -6,0 +6,0 @@ private location;

@@ -55,3 +55,3 @@ "use strict";

response.headers['location'] = this.location.toString();
return [2, Promise.resolve(response)];
return [2, response];
});

@@ -63,1 +63,2 @@ });

exports.CreatedNegotiatedContentResult = CreatedNegotiatedContentResult;
//# sourceMappingURL=CreatedNegotiatedContentResult.js.map
import { HttpResponseMessage } from '../httpResponseMessage';
import type { IHttpActionResult } from '../interfaces';
import { IHttpActionResult } from '../interfaces';
export declare class ExceptionResult implements IHttpActionResult {

@@ -4,0 +4,0 @@ private error;

@@ -53,3 +53,3 @@ "use strict";

response.content = new stringContent_1.StringContent(this.error.toString());
return [2, Promise.resolve(response)];
return [2, response];
});

@@ -61,1 +61,2 @@ });

exports.ExceptionResult = ExceptionResult;
//# sourceMappingURL=ExceptionResult.js.map

@@ -0,0 +0,0 @@ export * from './ExceptionResult';

@@ -26,1 +26,2 @@ "use strict";

__exportStar(require("./JsonResult"), exports);
//# sourceMappingURL=index.js.map
import { HttpResponseMessage } from '../httpResponseMessage';
import type { IHttpActionResult } from '../interfaces';
import { IHttpActionResult } from '../interfaces';
export declare class InternalServerErrorResult implements IHttpActionResult {
executeAsync(): Promise<HttpResponseMessage>;
}

@@ -48,3 +48,3 @@ "use strict";

return __generator(this, function (_a) {
return [2, Promise.resolve(new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR))];
return [2, new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR)];
});

@@ -56,1 +56,2 @@ });

exports.InternalServerErrorResult = InternalServerErrorResult;
//# sourceMappingURL=InternalServerError.js.map
import { HttpResponseMessage } from '../httpResponseMessage';
import type { IHttpActionResult } from '../interfaces';
export declare class JsonResult<T extends Record<string, unknown>> implements IHttpActionResult {
readonly json: T | T[];
import { IHttpActionResult } from '../interfaces';
export declare class JsonResult implements IHttpActionResult {
readonly json: any;
readonly statusCode: number;
constructor(json: T | T[], statusCode: number);
constructor(json: any, statusCode: number);
executeAsync(): Promise<HttpResponseMessage>;
}

@@ -40,4 +40,4 @@ "use strict";

exports.JsonResult = void 0;
var httpResponseMessage_1 = require("../httpResponseMessage");
var jsonContent_1 = require("../content/jsonContent");
var httpResponseMessage_1 = require("../httpResponseMessage");
var JsonResult = (function () {

@@ -54,3 +54,3 @@ function JsonResult(json, statusCode) {

response.content = new jsonContent_1.JsonContent(this.json);
return [2, Promise.resolve(response)];
return [2, response];
});

@@ -62,1 +62,2 @@ });

exports.JsonResult = JsonResult;
//# sourceMappingURL=JsonResult.js.map
import { HttpResponseMessage } from '../httpResponseMessage';
import type { IHttpActionResult } from '../interfaces';
import { IHttpActionResult } from '../interfaces';
export declare class NotFoundResult implements IHttpActionResult {
executeAsync(): Promise<HttpResponseMessage>;
}

@@ -48,3 +48,3 @@ "use strict";

return __generator(this, function (_a) {
return [2, Promise.resolve(new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.NOT_FOUND))];
return [2, new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.NOT_FOUND)];
});

@@ -56,1 +56,2 @@ });

exports.NotFoundResult = NotFoundResult;
//# sourceMappingURL=NotFoundResult.js.map
import { HttpResponseMessage } from '../httpResponseMessage';
import type { IHttpActionResult } from '../interfaces';
import { IHttpActionResult } from '../interfaces';
export declare class OkNegotiatedContentResult<T> implements IHttpActionResult {

@@ -4,0 +4,0 @@ private content;

@@ -53,3 +53,3 @@ "use strict";

response.content = new stringContent_1.StringContent(JSON.stringify(this.content));
return [2, Promise.resolve(response)];
return [2, response];
});

@@ -61,1 +61,2 @@ });

exports.OkNegotiatedContentResult = OkNegotiatedContentResult;
//# sourceMappingURL=OkNegotiatedContentResult.js.map
import { HttpResponseMessage } from '../httpResponseMessage';
import type { IHttpActionResult } from '../interfaces';
import { IHttpActionResult } from '../interfaces';
export declare class OkResult implements IHttpActionResult {
executeAsync(): Promise<HttpResponseMessage>;
}

@@ -48,3 +48,3 @@ "use strict";

return __generator(this, function (_a) {
return [2, Promise.resolve(new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.OK))];
return [2, new httpResponseMessage_1.HttpResponseMessage(http_status_codes_1.StatusCodes.OK)];
});

@@ -56,1 +56,2 @@ });

exports.OkResult = OkResult;
//# sourceMappingURL=OkResult.js.map
/// <reference types="node" />
import { URL } from 'node:url';
import { URL } from 'url';
import { HttpResponseMessage } from '../httpResponseMessage';
import type { IHttpActionResult } from '../interfaces';
import { IHttpActionResult } from '../interfaces';
export declare class RedirectResult implements IHttpActionResult {

@@ -6,0 +6,0 @@ private location;

@@ -52,3 +52,3 @@ "use strict";

response.headers['location'] = this.location.toString();
return [2, Promise.resolve(response)];
return [2, response];
});

@@ -60,1 +60,2 @@ });

exports.RedirectResult = RedirectResult;
//# sourceMappingURL=RedirectResult.js.map
import { HttpResponseMessage } from '../httpResponseMessage';
import type { IHttpActionResult } from '../interfaces';
import { IHttpActionResult } from '../interfaces';
export declare class ResponseMessageResult implements IHttpActionResult {

@@ -4,0 +4,0 @@ private message;

@@ -47,3 +47,3 @@ "use strict";

return __generator(this, function (_a) {
return [2, Promise.resolve(this.message)];
return [2, this.message];
});

@@ -55,1 +55,2 @@ });

exports.ResponseMessageResult = ResponseMessageResult;
//# sourceMappingURL=ResponseMessageResult.js.map
import { HttpResponseMessage } from '../httpResponseMessage';
import type { IHttpActionResult } from '../interfaces';
import { IHttpActionResult } from '../interfaces';
export declare class StatusCodeResult implements IHttpActionResult {

@@ -4,0 +4,0 @@ private statusCode;

@@ -48,3 +48,3 @@ "use strict";

return __generator(this, function (_a) {
return [2, Promise.resolve(new httpResponseMessage_1.HttpResponseMessage(this.statusCode))];
return [2, new httpResponseMessage_1.HttpResponseMessage(this.statusCode)];
});

@@ -56,1 +56,2 @@ });

exports.StatusCodeResult = StatusCodeResult;
//# sourceMappingURL=StatusCodeResult.js.map

@@ -1,4 +0,4 @@

import express, { Application, Router } from 'express';
import { interfaces } from 'inversify';
import type { AuthProvider, ConfigFunction, RoutingConfig } from './interfaces';
import * as express from 'express';
import * as inversify from 'inversify';
import * as interfaces from './interfaces';
export declare class InversifyExpressServer {

@@ -13,5 +13,5 @@ private _router;

private _forceControllers;
constructor(container: interfaces.Container, customRouter?: Router | null, routingConfig?: RoutingConfig | null, customApp?: Application | null, authProvider?: (new () => AuthProvider) | null, forceControllers?: boolean);
setConfig(fn: ConfigFunction): InversifyExpressServer;
setErrorConfig(fn: ConfigFunction): InversifyExpressServer;
constructor(container: inversify.interfaces.Container, customRouter?: express.Router | null, routingConfig?: interfaces.RoutingConfig | null, customApp?: express.Application | null, authProvider?: (new () => interfaces.AuthProvider) | null, forceControllers?: boolean);
setConfig(fn: interfaces.ConfigFunction): InversifyExpressServer;
setErrorConfig(fn: interfaces.ConfigFunction): InversifyExpressServer;
build(): express.Application;

@@ -18,0 +18,0 @@ private registerControllers;

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -68,3 +49,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

exports.InversifyExpressServer = void 0;
var express_1 = __importStar(require("express"));
var express = require("express");
var index_1 = require("./index");

@@ -79,7 +60,7 @@ var utils_1 = require("./utils");

this._forceControllers = forceControllers;
this._router = customRouter || (0, express_1.Router)();
this._router = customRouter || express.Router();
this._routingConfig = routingConfig || {
rootPath: constants_1.DEFAULT_ROUTING_ROOT_PATH,
};
this._app = customApp || (0, express_1.default)();
this._app = customApp || express();
if (authProvider) {

@@ -102,3 +83,3 @@ this._AuthProvider = authProvider;

this._app.all('*', function (req, res, next) {
void (function () { return __awaiter(_this, void 0, void 0, function () {
(function () { return __awaiter(_this, void 0, void 0, function () {
var httpContext;

@@ -128,5 +109,3 @@ return __generator(this, function (_a) {

var _this = this;
this._container
.bind(constants_1.TYPE.HttpContext)
.toConstantValue({});
this._container.bind(constants_1.TYPE.HttpContext).toConstantValue({});
var constructors = (0, utils_1.getControllersFromMetadata)();

@@ -157,3 +136,3 @@ constructors.forEach(function (constructor) {

var routeMiddleware = _this.resolveMidleware.apply(_this, metadata.middleware);
(_a = _this._router)[metadata.method].apply(_a, __spreadArray(__spreadArray(__spreadArray(["".concat(controllerMetadata.path).concat(metadata.path)], controllerMiddleware_1, false), routeMiddleware, false), [handler], false));
(_a = _this._router)[metadata.method].apply(_a, __spreadArray(__spreadArray(__spreadArray(["" + controllerMetadata.path + metadata.path], controllerMiddleware_1, false), routeMiddleware, false), [handler], false));
});

@@ -174,12 +153,11 @@ }

}
var middlewareInstance = _this._container
.get(middlewareItem);
if (middlewareInstance instanceof index_1.BaseMiddleware) {
var m = _this._container.get(middlewareItem);
if (m instanceof index_1.BaseMiddleware) {
return function (req, res, next) {
var mReq = _this._container.get(middlewareItem);
mReq.httpContext = _this._getHttpContext(req);
(mReq).httpContext = _this._getHttpContext(req);
mReq.handler(req, res, next);
};
}
return middlewareInstance;
return m;
});

@@ -205,3 +183,3 @@ };

.send;
return [4, message.content.readAsync()];
return [4, message.content.readAsStringAsync()];
case 1:

@@ -281,6 +259,6 @@ _b.apply(_a, [_c.sent()]);

return [2, {
container: this._container.createChild(),
request: req,
response: res,
user: principal
container: this._container.createChild(),
user: principal,
}];

@@ -302,4 +280,4 @@ }

isAuthenticated: function () { return Promise.resolve(false); },
isInRole: function (_role) { return Promise.resolve(false); },
isResourceOwner: function (_resourceId) { return Promise.resolve(false); },
isInRole: function (role) { return Promise.resolve(false); },
isResourceOwner: function (resourceId) { return Promise.resolve(false); },
})];

@@ -364,1 +342,2 @@ });

exports.InversifyExpressServer = InversifyExpressServer;
//# sourceMappingURL=server.js.map
import { interfaces } from 'inversify';
import type { Controller, ControllerMetadata, ControllerMethodMetadata, ControllerParameterMetadata, DecoratorTarget, IHttpActionResult } from './interfaces';
import { Controller, ControllerMetadata, ControllerMethodMetadata, ControllerParameterMetadata, IHttpActionResult } from './interfaces';
export declare function getControllersFromContainer(container: interfaces.Container, forceControllers: boolean): Array<Controller>;
export declare function getControllersFromMetadata(): Array<DecoratorTarget>;
export declare function getControllerMetadata(constructor: NewableFunction): ControllerMetadata;
export declare function getControllerMethodMetadata(constructor: NewableFunction): Array<ControllerMethodMetadata>;
export declare function getControllerParameterMetadata(constructor: NewableFunction): ControllerParameterMetadata;
export declare function getControllersFromMetadata(): Array<new () => Controller>;
export declare function getControllerMetadata(constructor: any): ControllerMetadata;
export declare function getControllerMethodMetadata(constructor: any): Array<ControllerMethodMetadata>;
export declare function getControllerParameterMetadata(constructor: any): ControllerParameterMetadata;
export declare function cleanUpMetadata(): void;
export declare function instanceOfIHttpActionResult(value: unknown): value is IHttpActionResult;
export declare function instanceOfIHttpActionResult(value: any): value is IHttpActionResult;

@@ -67,5 +67,5 @@ "use strict";

function instanceOfIHttpActionResult(value) {
return value != null &&
typeof value.executeAsync === 'function';
return value != null && typeof value.executeAsync === 'function';
}
exports.instanceOfIHttpActionResult = instanceOfIHttpActionResult;
//# sourceMappingURL=utils.js.map
{
"author": "Cody Simms",
"bugs": {
"url": "https://github.com/inversify/inversify-express-utils/issues"
},
"dependencies": {
"express": "4.17.3",
"http-status-codes": "2.2.0",
"inversify": "6.0.1"
},
"name": "inversify-express-utils",
"version": "6.4.6",
"description": "Some utilities for the development of express applications with Inversify",
"devDependencies": {
"@types/async": "3.2.12",
"@types/cookie-parser": "1.4.2",
"@types/express": "4.17.13",
"@types/jest": "27.4.0",
"@types/node": "17.0.13",
"@types/supertest": "2.0.11",
"@typescript-eslint/eslint-plugin": "5.10.1",
"@typescript-eslint/parser": "5.10.1",
"async": "3.2.3",
"cookie-parser": "1.4.6",
"eslint": "8.7.0",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-typescript-sort-keys": "2.1.0",
"jest": "27.4.7",
"publish-please": "5.5.2",
"reflect-metadata": "0.1.13",
"supertest": "6.2.2",
"ts-jest": "27.1.3",
"typescript": "4.5.5",
"updates": "13.0.0"
},
"homepage": "https://github.com/inversify/inversify-express-utils#readme",
"main": "lib/index.js",
"jsnext:main": "es/index.js",
"keywords": [
"InversifyJS",
"express"
],
"license": "MIT",
"main": "lib/index.js",
"module": "es/index.js",
"name": "inversify-express-utils",
"repository": {
"type": "git",
"url": "git+https://github.com/inversify/inversify-express-utils.git"
},
"types": "./lib/index.d.ts",
"scripts": {

@@ -55,3 +16,2 @@ "build": "npm run build:lib && npm run build:es && npm run build:es6",

"test": "jest",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch",

@@ -64,4 +24,48 @@ "pretest": "eslint ./",

},
"types": "./lib/index.d.ts",
"version": "6.4.5"
"repository": {
"type": "git",
"url": "git+https://github.com/inversify/inversify-express-utils.git"
},
"keywords": [
"InversifyJS",
"express"
],
"author": "Cody Simms",
"license": "MIT",
"bugs": {
"url": "https://github.com/inversify/inversify-express-utils/issues"
},
"homepage": "https://github.com/inversify/inversify-express-utils#readme",
"devDependencies": {
"@types/async": "3.2.8",
"@types/cookie-parser": "1.4.2",
"@types/express": "4.17.13",
"@types/jest": "27.0.2",
"@types/node": "16.11.1",
"@types/sinon": "10.0.4",
"@types/supertest": "2.0.11",
"@typescript-eslint/eslint-plugin": "5.1.0",
"@typescript-eslint/parser": "5.1.0",
"async": "3.2.1",
"cookie-parser": "1.4.5",
"eslint": "8.0.1",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-airbnb-typescript": "14.0.1",
"eslint-plugin-import": "2.25.2",
"jest": "27.3.1",
"jest-junit": "13.0.0",
"jest-simple-dot-reporter": "1.0.5",
"prettyjson": "1.2.1",
"publish-please": "5.5.2",
"reflect-metadata": "0.1.13",
"supertest": "6.1.6",
"ts-jest": "27.0.7",
"typescript": "4.4.4",
"updates": "12.2.2"
},
"dependencies": {
"express": "^4.17.1",
"http-status-codes": "^2.1.4",
"inversify": "^6.0.1"
}
}

@@ -480,5 +480,5 @@ # inversify-express-utils

```ts
class Principal implements interfaces.Principal<T = unknown> {
public details: T;
public constructor(details: T) {
class Principal implements interfaces.Principal {
public details: any;
public constructor(details: any) {
this.details = details;

@@ -489,3 +489,3 @@ }

}
public isResourceOwner(resourceId: unknown): Promise<boolean> {
public isResourceOwner(resourceId: any): Promise<boolean> {
return Promise.resolve(resourceId === 1111);

@@ -492,0 +492,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc