@seam-rpc/client 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,9 +20,9 @@ export interface SeamClientOptions {
|
|
|
20
20
|
}
|
|
21
21
|
export declare class SeamClient {
|
|
22
22
|
readonly baseUrl: string;
|
|
23
|
-
readonly options?: SeamClientOptions | undefined;
|
|
24
23
|
static _instance: SeamClient;
|
|
25
|
-
|
|
24
|
+
options: SeamClientOptions;
|
|
25
|
+
constructor(baseUrl: string, options?: SeamClientOptions);
|
|
26
26
|
preRequest(middleware: SeamRequestMiddleware): void;
|
|
27
27
|
postRequest(middleware: SeamResponseMiddleware): void;
|
|
28
28
|
}
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,13 @@ export { SeamFile };
|
|
|
3
3
|
export class SeamClient {
|
|
4
4
|
constructor(baseUrl, options) {
|
|
5
5
|
this.baseUrl = baseUrl;
|
|
6
|
-
this.options = options;
|
|
7
6
|
SeamClient._instance = this;
|
|
7
|
+
this.options = {
|
|
8
|
+
middleware: {
|
|
9
|
+
request: options?.middleware?.request || [],
|
|
10
|
+
response: options?.middleware?.response || [],
|
|
11
|
+
}
|
|
12
|
+
};
|
|
8
13
|
}
|
|
9
14
|
preRequest(middleware) {
|
|
10
15
|
this.options?.middleware?.request?.push(middleware);
|
|
@@ -45,7 +50,7 @@ export async function callApi(routerName, funcName, args) {
|
|
|
45
50
|
const resError = await res.json();
|
|
46
51
|
throw new Error(resError.error);
|
|
47
52
|
}
|
|
48
|
-
throw new Error(`Request failed with status ${res.status} ${res.statusText}.`);
|
|
53
|
+
throw new Error(`Request failed at router ${routerName} at function ${funcName}, with status ${res.status} ${res.statusText}.`);
|
|
49
54
|
}
|
|
50
55
|
const contentType = res.headers.get("content-type") || "";
|
|
51
56
|
if (contentType.startsWith("application/json")) {
|