@push-rpc/next
Advanced tools
Comparing version 2.0.13 to 2.0.14
@@ -46,3 +46,3 @@ "use strict"; | ||
if (response.status < 200 || response.status >= 300) { | ||
const error = new Error(response.statusText); | ||
const error = new Error(response.headers.get("x-error") ?? undefined); | ||
Object.assign(error, { code: response.status }); | ||
@@ -49,0 +49,0 @@ if (typeof res == "object") { |
@@ -54,3 +54,5 @@ "use strict"; | ||
res.statusCode = e.code; | ||
res.statusMessage = e.message; | ||
if (e.message) { | ||
res.setHeader("X-Error", e["message"]); | ||
} | ||
const { code, message, stack, ...rest } = e; | ||
@@ -67,3 +69,5 @@ if (Object.keys(rest).length > 0) { | ||
res.statusCode = 500; | ||
res.statusMessage = e["message"] || "Internal Server Error"; | ||
if (e["message"]) { | ||
res.setHeader("X-Error", e["message"]); | ||
} | ||
res.end(); | ||
@@ -70,0 +74,0 @@ return; |
{ | ||
"name": "@push-rpc/next", | ||
"version": "2.0.13", | ||
"version": "2.0.14", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -8,4 +8,5 @@ import {CLIENT_ID_HEADER, RpcErrors} from "../rpc.js" | ||
private clientId: string, | ||
private getHeaders: () => Promise<Record<string, string>> | ||
) {} | ||
private getHeaders: () => Promise<Record<string, string>>, | ||
) { | ||
} | ||
@@ -33,3 +34,3 @@ async call(itemName: string, params: unknown[], callTimeout: number): Promise<unknown> { | ||
callTimeout: number, | ||
headers: Record<string, string> | ||
headers: Record<string, string>, | ||
): Promise<unknown> { | ||
@@ -66,3 +67,3 @@ const itemUrl = this.getItemUrl(itemName) | ||
if (response.status < 200 || response.status >= 300) { | ||
const error = new Error(response.statusText) | ||
const error = new Error(response.headers.get("x-error") ?? undefined) | ||
@@ -69,0 +70,0 @@ Object.assign(error, {code: response.status}) |
@@ -13,3 +13,3 @@ import * as http from "http" | ||
hooks: HttpServerHooks, | ||
createConnectionContext: (req: IncomingMessage) => Promise<RpcConnectionContext> | ||
createConnectionContext: (req: IncomingMessage) => Promise<RpcConnectionContext>, | ||
) { | ||
@@ -69,3 +69,6 @@ // if port is in options - response 404 on other URLs | ||
res.statusCode = e.code | ||
res.statusMessage = e.message | ||
if (e.message) { | ||
res.setHeader("X-Error", e["message"]) | ||
} | ||
const {code, message, stack, ...rest} = e | ||
@@ -82,3 +85,5 @@ if (Object.keys(rest).length > 0) { | ||
res.statusCode = 500 | ||
res.statusMessage = e["message"] || "Internal Server Error" | ||
if (e["message"]) { | ||
res.setHeader("X-Error", e["message"]) | ||
} | ||
res.end() | ||
@@ -113,3 +118,3 @@ return | ||
itemName: string, | ||
parameters: unknown[] | ||
parameters: unknown[], | ||
): Promise<unknown> | ||
@@ -119,4 +124,4 @@ unsubscribe( | ||
itemName: string, | ||
parameters: unknown[] | ||
parameters: unknown[], | ||
): Promise<unknown> | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
225451
4948