fix(core): update
This commit is contained in:
parent
e0c75716d7
commit
649db1059c
@ -5,7 +5,7 @@
|
|||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "apiglobal",
|
"gitscope": "apiglobal",
|
||||||
"gitrepo": "typedrequest",
|
"gitrepo": "typedrequest",
|
||||||
"shortDescription": "make typed requests towards apis",
|
"description": "make typed requests towards apis",
|
||||||
"npmPackagename": "@apiglobal/typedrequest",
|
"npmPackagename": "@apiglobal/typedrequest",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"projectDomain": "api.global"
|
"projectDomain": "api.global"
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@apiglobal/typedrequest',
|
name: '@apiglobal/typedrequest',
|
||||||
version: '2.0.10',
|
version: '2.0.11',
|
||||||
description: 'make typed requests towards apis'
|
description: 'make typed requests towards apis'
|
||||||
}
|
}
|
||||||
|
@ -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,15 +41,15 @@ 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);
|
||||||
typedRouterArg.addTypedRouter(this);
|
typedRouterArg.addTypedRouter(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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> {
|
||||||
@ -86,8 +86,10 @@ 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 = plugins.typedRequestInterfaces.ITypedRequest> (typedRequestArg: T): Promise<T> {
|
public async routeAndAddResponse<
|
||||||
if (typedRequestArg?.correlation?.phase === 'request') {
|
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);
|
const typedHandler = this.getTypedHandlerForMethod(typedRequestArg.method);
|
||||||
|
|
||||||
if (!typedHandler) {
|
if (!typedHandler) {
|
||||||
@ -110,7 +112,7 @@ export class TypedRouter {
|
|||||||
} else {
|
} else {
|
||||||
console.log('received weirdly shaped request');
|
console.log('received weirdly shaped request');
|
||||||
console.log(typedRequestArg);
|
console.log(typedRequestArg);
|
||||||
return null
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user