Skip to content

Commit 513207e

Browse files
authored
Add default onError (#28)
1 parent a53983c commit 513207e

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

deno.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@userhub/sdk",
3-
"version": "0.6.2",
3+
"version": "0.6.3",
44
"exports": "./src/mod.ts",
55
"lint": {
66
"include": ["src/", "test/deno"],

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@userhub/sdk",
3-
"version": "0.6.2",
3+
"version": "0.6.3",
44
"description": "UserHub JavaScript SDK",
55
"license": "MIT",
66
"author": "UserHub (https://userhub.com/)",

src/internal/constants.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Code generated. DO NOT EDIT.
22

33
export const API_BASE_URL = "https://api.userhub.com";
4-
export const USER_AGENT = "UserHub-JavaScript/0.6.2";
5-
export const VERSION = "0.6.2";
4+
export const USER_AGENT = "UserHub-JavaScript/0.6.3";
5+
export const VERSION = "0.6.3";
66

77
export const AUTH_HEADER = "Authorization";
88
export const API_KEY_HEADER = "UserHub-Api-Key";

src/webhook/base.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,8 @@ export class BaseWebhook {
5757
if (!signingSecret && options.signingSecret) {
5858
signingSecret = options.signingSecret;
5959
}
60-
if (options.onError) {
61-
this._onError = options.onError;
62-
}
6360

61+
this._onError = options.onError || defaultOnError;
6462
this._signingSecret = signingSecret;
6563
}
6664

@@ -340,3 +338,9 @@ export function webhookStatusCode(code: Code): number {
340338
return 500;
341339
}
342340
}
341+
342+
function defaultOnError(e: unknown) {
343+
if (e) {
344+
console.error("UserHub webhook:", e);
345+
}
346+
}

test/node/webhook.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ test.each<WebhookTest>([
321321
addSignature: true,
322322
},
323323
])("handler: $name", async (test) => {
324-
const webhook = new Webhook(test.secret);
324+
const webhook = new Webhook(test.secret, { onError: () => {} });
325325

326326
webhook.onEvent((input: eventsv1.Event) => {
327327
if (input.type !== "ok") {

0 commit comments

Comments
 (0)