fix(core): update

This commit is contained in:
Philipp Kunz 2022-10-09 18:52:49 +02:00
parent e0c75716d7
commit 649db1059c
3 changed files with 12 additions and 10 deletions

View File

@ -5,7 +5,7 @@
"githost": "gitlab.com",
"gitscope": "apiglobal",
"gitrepo": "typedrequest",
"shortDescription": "make typed requests towards apis",
"description": "make typed requests towards apis",
"npmPackagename": "@apiglobal/typedrequest",
"license": "MIT",
"projectDomain": "api.global"

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@apiglobal/typedrequest',
version: '2.0.10',
version: '2.0.11',
description: 'make typed requests towards apis'
}

View File

@ -23,7 +23,7 @@ export class TypedRouter {
* adds the handler to the routing map
* @param typedHandlerArg
*/
public addTypedHandler<T extends plugins.typedRequestInterfaces.ITypedRequest> (
public addTypedHandler<T extends plugins.typedRequestInterfaces.ITypedRequest>(
typedHandlerArg: TypedHandler<T>
) {
// lets check for deduplication
@ -41,15 +41,15 @@ export class TypedRouter {
* adds another sub typedRouter
* @param typedRequest
*/
public addTypedRouter (typedRouterArg: TypedRouter) {
const routerExists = this.routerMap.findSync(routerArg => routerArg === typedRouterArg)
public addTypedRouter(typedRouterArg: TypedRouter) {
const routerExists = this.routerMap.findSync((routerArg) => routerArg === typedRouterArg);
if (!routerExists) {
this.routerMap.add(typedRouterArg);
typedRouterArg.addTypedRouter(this);
}
}
public checkForTypedHandler (methodArg: string): boolean {
public checkForTypedHandler(methodArg: string): boolean {
return !!this.getTypedHandlerForMethod(methodArg);
}
@ -58,7 +58,7 @@ export class TypedRouter {
* @param methodArg
* @param checkUpstreamRouter
*/
public getTypedHandlerForMethod (
public getTypedHandlerForMethod(
methodArg: string,
checkedRouters: TypedRouter[] = []
): TypedHandler<any> {
@ -86,8 +86,10 @@ export class TypedRouter {
* if typedrequest object has correlation.phase === 'response' -> routes a typed request object to request fire event
* @param typedRequestArg
*/
public async routeAndAddResponse<T extends plugins.typedRequestInterfaces.ITypedRequest = plugins.typedRequestInterfaces.ITypedRequest> (typedRequestArg: T): Promise<T> {
if (typedRequestArg?.correlation?.phase === 'request') {
public async routeAndAddResponse<
T extends plugins.typedRequestInterfaces.ITypedRequest = plugins.typedRequestInterfaces.ITypedRequest
>(typedRequestArg: T, localRequestArg = false): Promise<T> {
if (typedRequestArg?.correlation?.phase === 'request' || localRequestArg) {
const typedHandler = this.getTypedHandlerForMethod(typedRequestArg.method);
if (!typedHandler) {
@ -110,7 +112,7 @@ export class TypedRouter {
} else {
console.log('received weirdly shaped request');
console.log(typedRequestArg);
return null
return null;
}
}
}