@betit/orion-node-sdk
Advanced tools
Comparing version 1.0.0-beta.40 to 1.0.0-beta.41
import { OrionError } from '../error/error'; | ||
export declare class Response { | ||
payload: any; | ||
export declare class Response<T = any> { | ||
payload: T; | ||
error: OrionError; | ||
constructor(payload: any, error?: OrionError); | ||
constructor(payload: T, error?: OrionError); | ||
} |
@@ -6,4 +6,4 @@ import { Options, Logger } from '../types/interfaces'; | ||
import { Dependency } from '../health/health'; | ||
export declare type CallbackRequestFunction = (d: Response) => any; | ||
export declare type CallbackHandleFunction = (req: Request, cb?: (res?: Response) => any) => Promise<Response> | void; | ||
export declare type CallbackRequestFunction<T = any> = (d: Response<T>) => any; | ||
export declare type CallbackHandleFunction<T = any> = (req: Request, cb?: (res?: Response<T>) => any) => Promise<Response<T>> | void; | ||
export declare function uniqueName(name: string, uniqueID: string): string; | ||
@@ -53,3 +53,3 @@ /** | ||
*/ | ||
handle(path: string, callback: CallbackHandleFunction, prefix?: string): void; | ||
handle<T = any>(path: string, callback: CallbackHandleFunction<T>, prefix?: string): void; | ||
/** | ||
@@ -61,3 +61,3 @@ * Register request handler method with disabled logging. | ||
*/ | ||
handleWithoutLogging(path: string, callback: CallbackHandleFunction, prefix?: string): void; | ||
handleWithoutLogging<T = any>(path: string, callback: CallbackHandleFunction<T>, prefix?: string): void; | ||
/** | ||
@@ -96,3 +96,3 @@ * Start listenning on the underlying transport connection. | ||
*/ | ||
call(req: Request, callback?: CallbackRequestFunction): Promise<Response>; | ||
call<T = any>(req: Request, callback?: CallbackRequestFunction<T>): Promise<Response<T>>; | ||
private _getCallTimeout(path, timeout); | ||
@@ -99,0 +99,0 @@ private _call(route, req, callback); |
@@ -134,3 +134,8 @@ "use strict"; | ||
.then(afterCallback) | ||
.catch((err) => { throw err; }); | ||
.catch((err) => { | ||
if (err instanceof error_1.OrionError) { | ||
afterCallback(new response_1.Response(null, err)); | ||
} | ||
throw err; | ||
}); | ||
} | ||
@@ -137,0 +142,0 @@ }); |
{ | ||
"name": "@betit/orion-node-sdk", | ||
"version": "1.0.0-beta.40", | ||
"version": "1.0.0-beta.41", | ||
"description": "SDK for orion", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1744838
3255