arrow-express
Advanced tools
Comparing version 2.1.4 to 2.1.5
@@ -31,4 +31,4 @@ import Express from "express"; | ||
private printExpressConfig; | ||
private startControllers; | ||
private startController; | ||
private configureControllers; | ||
private configureController; | ||
private registerRouteInExpress; | ||
@@ -35,0 +35,0 @@ private createApplicationRequestHandler; |
@@ -38,2 +38,11 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -69,3 +78,3 @@ exports.Application = exports.AppConfigurator = void 0; | ||
} | ||
this.startControllers(); | ||
this.configureControllers(); | ||
if (printConfiguration) { | ||
@@ -101,7 +110,7 @@ this.printExpressConfig(); | ||
}; | ||
AppConfigurator.prototype.startControllers = function () { | ||
AppConfigurator.prototype.configureControllers = function () { | ||
var _this = this; | ||
this._controllers.forEach(function (controller) { return _this.startController(controller); }); | ||
this._controllers.forEach(function (controller) { return _this.configureController(controller); }); | ||
}; | ||
AppConfigurator.prototype.startController = function (controller, controllersChain) { | ||
AppConfigurator.prototype.configureController = function (controller, controllersChain) { | ||
var _this = this; | ||
@@ -112,6 +121,6 @@ if (!controllersChain) { | ||
else { | ||
controllersChain.push(controller); | ||
controllersChain = __spreadArray(__spreadArray([], controllersChain, true), [controller], false); | ||
} | ||
controller.getControllers().forEach(function (subController) { | ||
_this.startController(subController, controllersChain); | ||
_this.configureController(subController, controllersChain); | ||
}); | ||
@@ -118,0 +127,0 @@ controller.getRoutes().forEach(function (route) { |
@@ -13,3 +13,3 @@ import { RouteConfigurator } from "../route/route"; | ||
*/ | ||
registerController(controller: ControllerConfiguration<unknown, Context>): this; | ||
registerController(controller: ControllerConfiguration<any, Context>): this; | ||
/** | ||
@@ -19,3 +19,3 @@ * Register array of controllers in controller | ||
*/ | ||
registerControllers(...controllers: ControllerConfiguration<unknown>[]): this; | ||
registerControllers(...controllers: ControllerConfiguration<any, Context>[]): this; | ||
/** | ||
@@ -22,0 +22,0 @@ * Register route in controller |
@@ -85,2 +85,3 @@ import Express from "express"; | ||
.prefix("root") | ||
.registerRoute(Route().path("path").method("get").handler(handlerSpy)) | ||
.registerController(Controller().prefix("sub").registerRoute(Route().method("get").handler(handlerSpy))) | ||
@@ -90,2 +91,3 @@ ) | ||
expect(ExpressAppStub.get).toHaveBeenCalledWith("/root/sub", expect.any(Function)); | ||
expect(ExpressAppStub.get).toHaveBeenCalledWith("/root/path", expect.any(Function)); | ||
}); | ||
@@ -92,0 +94,0 @@ }); |
@@ -36,3 +36,3 @@ import Express from "express"; | ||
} | ||
this.startControllers(); | ||
this.configureControllers(); | ||
if (printConfiguration) { | ||
@@ -68,14 +68,14 @@ this.printExpressConfig(); | ||
private startControllers() { | ||
this._controllers.forEach(controller => this.startController(controller)); | ||
private configureControllers() { | ||
this._controllers.forEach(controller => this.configureController(controller)); | ||
} | ||
private startController(controller: ControllerConfiguration, controllersChain?: ControllerConfiguration[]) { | ||
private configureController(controller: ControllerConfiguration, controllersChain?: ControllerConfiguration[]) { | ||
if (!controllersChain) { | ||
controllersChain = [controller]; | ||
} else { | ||
controllersChain.push(controller); | ||
controllersChain = [...controllersChain, controller]; | ||
} | ||
controller.getControllers().forEach(subController => { | ||
this.startController(subController, controllersChain); | ||
this.configureController(subController, controllersChain); | ||
}); | ||
@@ -82,0 +82,0 @@ controller.getRoutes().forEach(route => { |
{ | ||
"name": "arrow-express", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"description": "Library to bootstrap express applications with zero configuration", | ||
@@ -5,0 +5,0 @@ "main": "dist/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
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
799341
15826