routes-utility
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -12,4 +12,4 @@ /// <reference types="when" /> | ||
} | ||
export interface IProgression { | ||
lastExecutedController: string; | ||
export interface IProgression<C> { | ||
lastExecutedController: C; | ||
nextIndex: number; | ||
@@ -48,3 +48,3 @@ routeSize: number; | ||
addController(controller: Controller<CONTEXT, INIT_REQ, any, any, FINAL_RES>): this; | ||
match(req: INIT_REQ, context: CONTEXT, onProgress?: (progression: IProgression) => any): When.Promise<FINAL_RES>; | ||
match(req: INIT_REQ, context: CONTEXT, onProgress?: (progression: IProgression<Controller<CONTEXT, INIT_REQ, any, any, FINAL_RES>>) => any): When.Promise<FINAL_RES>; | ||
readonly name: string; | ||
@@ -51,0 +51,0 @@ readonly statistics: IRouteStatistics; |
@@ -50,3 +50,3 @@ "use strict"; | ||
throw new sw_logger_1.CustomError("invalidRoute", "route %s does not contain any controller", this._name); | ||
let index = 0, currentController = this._controllers[index], lastExecutedController, onProgressFns = [], def = When.defer(), finish = (res) => { | ||
let index = 0, currentController = this._controllers[index], lastExecutedController, def = When.defer(), finish = (res) => { | ||
if (_.isFinite(this._statistics.PENDING.STAGES[lastExecutedController.name])) | ||
@@ -62,4 +62,2 @@ this._statistics.PENDING.STAGES[lastExecutedController.name]--; | ||
}; | ||
if (onProgress != void 0) | ||
onProgressFns.push(onProgress); | ||
this._statistics.PENDING.TOTAL++; | ||
@@ -90,11 +88,12 @@ let next = (res, controller) => { | ||
this._statistics.PENDING.STAGES[currentController.name]++; | ||
When.all(_.map(onProgressFns, (pFn) => { | ||
return pFn({ | ||
lastExecutedController: lastExecutedController, | ||
nextIndex: index, | ||
routeSize: this._controllers.length, | ||
req: req, | ||
res: res | ||
}); | ||
})).then(() => { | ||
When(null).then(() => { | ||
if (_.isFunction(onProgress)) | ||
return onProgress({ | ||
lastExecutedController: lastExecutedController, | ||
nextIndex: index, | ||
routeSize: this._controllers.length, | ||
req: req, | ||
res: res | ||
}); | ||
}).then(() => { | ||
lastExecutedController = currentController; | ||
@@ -101,0 +100,0 @@ currentController.body.call(context, req, res, next, finish); |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"scripts": { | ||
@@ -10,0 +10,0 @@ "test": "./node_modules/.bin/mocha --opts tests/mocha.opts tests/**/*.ts", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
16310
224