fix(core): update
This commit is contained in:
parent
362f3f1bd0
commit
c90aa07ace
@ -23,7 +23,7 @@ export class TypedRouter {
|
|||||||
* adds the handler to the routing map
|
* adds the handler to the routing map
|
||||||
* @param typedHandlerArg
|
* @param typedHandlerArg
|
||||||
*/
|
*/
|
||||||
public addTypedHandler<T extends plugins.typedRequestInterfaces.ITypedRequest>(
|
public addTypedHandler<T extends plugins.typedRequestInterfaces.ITypedRequest> (
|
||||||
typedHandlerArg: TypedHandler<T>
|
typedHandlerArg: TypedHandler<T>
|
||||||
) {
|
) {
|
||||||
// lets check for deduplication
|
// lets check for deduplication
|
||||||
@ -41,7 +41,7 @@ export class TypedRouter {
|
|||||||
* adds another sub typedRouter
|
* adds another sub typedRouter
|
||||||
* @param typedRequest
|
* @param typedRequest
|
||||||
*/
|
*/
|
||||||
public addTypedRouter(typedRouterArg: TypedRouter) {
|
public addTypedRouter (typedRouterArg: TypedRouter) {
|
||||||
const routerExists = this.routerMap.findSync(routerArg => routerArg === typedRouterArg)
|
const routerExists = this.routerMap.findSync(routerArg => routerArg === typedRouterArg)
|
||||||
if (!routerExists) {
|
if (!routerExists) {
|
||||||
this.routerMap.add(typedRouterArg);
|
this.routerMap.add(typedRouterArg);
|
||||||
@ -49,7 +49,7 @@ export class TypedRouter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public checkForTypedHandler(methodArg: string): boolean {
|
public checkForTypedHandler (methodArg: string): boolean {
|
||||||
return !!this.getTypedHandlerForMethod(methodArg);
|
return !!this.getTypedHandlerForMethod(methodArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ export class TypedRouter {
|
|||||||
* @param methodArg
|
* @param methodArg
|
||||||
* @param checkUpstreamRouter
|
* @param checkUpstreamRouter
|
||||||
*/
|
*/
|
||||||
public getTypedHandlerForMethod(
|
public getTypedHandlerForMethod (
|
||||||
methodArg: string,
|
methodArg: string,
|
||||||
checkedRouters: TypedRouter[] = []
|
checkedRouters: TypedRouter[] = []
|
||||||
): TypedHandler<any> {
|
): TypedHandler<any> {
|
||||||
@ -69,7 +69,7 @@ export class TypedRouter {
|
|||||||
typedHandler = this.handlerMap.findSync((handler) => {
|
typedHandler = this.handlerMap.findSync((handler) => {
|
||||||
return handler.method === methodArg;
|
return handler.method === methodArg;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!typedHandler) {
|
if (!typedHandler) {
|
||||||
this.routerMap.getArray().forEach((typedRouterArg) => {
|
this.routerMap.getArray().forEach((typedRouterArg) => {
|
||||||
if (!typedHandler && !checkedRouters.includes(typedRouterArg)) {
|
if (!typedHandler && !checkedRouters.includes(typedRouterArg)) {
|
||||||
@ -86,7 +86,7 @@ export class TypedRouter {
|
|||||||
* if typedrequest object has correlation.phase === 'response' -> routes a typed request object to request fire event
|
* if typedrequest object has correlation.phase === 'response' -> routes a typed request object to request fire event
|
||||||
* @param typedRequestArg
|
* @param typedRequestArg
|
||||||
*/
|
*/
|
||||||
public async routeAndAddResponse<T extends plugins.typedRequestInterfaces.ITypedRequest = any>(typedRequestArg: T): Promise<T> {
|
public async routeAndAddResponse<T extends plugins.typedRequestInterfaces.ITypedRequest = plugins.typedRequestInterfaces.ITypedRequest> (typedRequestArg: T): Promise<T> {
|
||||||
if (typedRequestArg?.correlation?.phase === 'request') {
|
if (typedRequestArg?.correlation?.phase === 'request') {
|
||||||
const typedHandler = this.getTypedHandlerForMethod(typedRequestArg.method);
|
const typedHandler = this.getTypedHandlerForMethod(typedRequestArg.method);
|
||||||
|
|
||||||
@ -106,6 +106,7 @@ export class TypedRouter {
|
|||||||
this.fireEventInterestMap
|
this.fireEventInterestMap
|
||||||
.findInterest(typedRequestArg.correlation.id)
|
.findInterest(typedRequestArg.correlation.id)
|
||||||
?.fullfillInterest(typedRequestArg);
|
?.fullfillInterest(typedRequestArg);
|
||||||
|
return null;
|
||||||
} else {
|
} else {
|
||||||
console.log('received weirdly shaped request');
|
console.log('received weirdly shaped request');
|
||||||
console.log(typedRequestArg);
|
console.log(typedRequestArg);
|
||||||
|
Loading…
Reference in New Issue
Block a user