@hirosystems/chainhook-client
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -27,2 +27,9 @@ /// <reference types="node" /> | ||
export type ChainhookNodeOptions = Static<typeof ChainhookNodeOptionsSchema>; | ||
/** | ||
* Throw this error when processing a Chainhook Payload if you believe it is a bad request. This | ||
* will cause the server to return a `400` status code. | ||
*/ | ||
export declare class BadPayloadRequestError extends Error { | ||
constructor(message: string); | ||
} | ||
declare const ServerPredicateSchema: import("@sinclair/typebox").TObject<{ | ||
@@ -29,0 +36,0 @@ uuid: import("@sinclair/typebox").TString; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.buildServer = void 0; | ||
exports.buildServer = exports.BadPayloadRequestError = void 0; | ||
const type_provider_typebox_1 = require("@fastify/type-provider-typebox"); | ||
@@ -29,2 +29,13 @@ const compiler_1 = require("@sinclair/typebox/compiler"); | ||
}); | ||
/** | ||
* Throw this error when processing a Chainhook Payload if you believe it is a bad request. This | ||
* will cause the server to return a `400` status code. | ||
*/ | ||
class BadPayloadRequestError extends Error { | ||
constructor(message) { | ||
super(message); | ||
this.name = this.constructor.name; | ||
} | ||
} | ||
exports.BadPayloadRequestError = BadPayloadRequestError; | ||
const IfThisThenNothingSchema = type_provider_typebox_1.Type.Union([ | ||
@@ -163,4 +174,10 @@ type_provider_typebox_1.Type.Composite([ | ||
catch (error) { | ||
logger_1.logger.error(error, `ChainhookEventObserver error processing payload`); | ||
await reply.code(500).send(); | ||
if (error instanceof BadPayloadRequestError) { | ||
logger_1.logger.error(error, `ChainhookEventObserver bad payload`); | ||
await reply.code(400).send(); | ||
} | ||
else { | ||
logger_1.logger.error(error, `ChainhookEventObserver error processing payload`); | ||
await reply.code(500).send(); | ||
} | ||
} | ||
@@ -167,0 +184,0 @@ }); |
{ | ||
"name": "@hirosystems/chainhook-client", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Chainhook TypeScript client", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
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
290347
4251