From 0be22af529966550b379e8e214bf4b0316b304c3 Mon Sep 17 00:00:00 2001 From: Tomasz Awramski Date: Wed, 22 May 2024 17:50:17 +0200 Subject: [PATCH] prettier and endpoint catch handling fix --- .../admin-enroll-v1-endpoint.test.ts | 10 +-- .../run-discounted-asset-trade-client.ts | 7 ++- .../counterparty-htlc-endpoint.ts | 8 +-- .../web-services/own-htlc-endpoint.ts | 7 +-- .../web-services/get-object-endpoint-v1.ts | 11 ++-- .../web-services/has-object-endpoint-v1.ts | 11 ++-- .../web-services/set-object-endpoint-v1.ts | 11 ++-- ...prometheus-exporter-metrics-endpoint-v1.ts | 13 ++-- .../default-consortium-provider.test.ts | 39 +++++++----- .../watch-healthcheck-v1-endpoint.ts | 3 +- .../web-services/deploy-contract-endpoint.ts | 12 ++-- .../web-services/run-transaction-endpoint.ts | 12 ++-- .../unprotected-action-endpoint.ts | 12 ++-- .../routing-interface/routes/login.ts | 8 +-- .../get-consortium-jws-endpoint-v1.ts | 4 +- .../consortium/get-node-jws-endpoint-v1.ts | 2 +- ...prometheus-exporter-metrics-endpoint-v1.ts | 10 ++- .../get-single-status-endpoint.ts | 7 ++- .../web-services/get-status-endpoint.ts | 7 ++- .../web-services/initialize-endpoint.ts | 7 ++- .../web-services/new-contract-endpoint.ts | 7 ++- .../web-services/refund-endpoint.ts | 7 ++- .../web-services/withdraw-endpoint.ts | 7 ++- .../get-single-status-endpoint.ts | 7 ++- .../web-services/get-status-endpoint.ts | 9 ++- .../web-services/initialize-endpoint.ts | 9 ++- .../web-services/new-contract-endpoint.ts | 11 ++-- .../web-services/refund-endpoint.ts | 7 ++- .../web-services/withdraw-endpoint.ts | 7 ++- .../delete-keychain-entry-endpoint-v1.ts | 7 ++- .../get-keychain-entry-endpoint-v1.ts | 32 +++++++--- ...prometheus-exporter-metrics-endpoint-v1.ts | 31 +++++++--- .../has-keychain-entry-endpoint-v1.ts | 7 ++- .../set-keychain-entry-endpoint-v1.ts | 7 ++- .../openapi/openapi-validation.test.ts | 62 +++++++++---------- .../delete-keychain-entry-endpoint.ts | 7 ++- .../get-keychain-entry-endpoint.ts | 33 +++++++--- .../has-keychain-entry-endpoint.ts | 7 ++- .../set-keychain-entry-endpoint.ts | 7 ++- .../delete-keychain-entry-endpoint-v1.ts | 7 ++- .../get-keychain-entry-endpoint-v1.ts | 34 +++++++--- .../has-keychain-entry-endpoint-v1.ts | 7 ++- .../set-keychain-entry-endpoint-v1.ts | 9 ++- .../openapi/openapi-validation.test.ts | 16 ++--- .../delete-keychain-entry-endpoint-v1.ts | 7 ++- .../get-keychain-entry-endpoint-v1.ts | 32 +++++++--- .../has-keychain-entry-endpoint-v1.ts | 7 ++- .../set-keychain-entry-endpoint-v1.ts | 7 ++- ...prometheus-exporter-metrics-endpoint-v1.ts | 37 ++++++++--- .../main/typescript/plugin-keychain-vault.ts | 7 ++- .../delete-keychain-entry-endpoint-v1.ts | 7 ++- .../get-keychain-entry-endpoint-v1.ts | 7 ++- ...prometheus-exporter-metrics-endpoint-v1.ts | 10 ++- .../has-keychain-entry-endpoint-v1.ts | 7 ++- .../set-keychain-entry-endpoint-v1.ts | 7 ++- .../accept-invitation-v1-endpoint.ts | 13 ++-- ...e-new-connection-invitation-v1-endpoint.ts | 16 +++-- .../web-services/get-agents-v1-endpoint.ts | 13 ++-- .../get-connections-v1-endpoint.ts | 13 ++-- .../web-services/request-proof-v1-endpoint.ts | 13 ++-- .../web-services/get-balance-endpoint.ts | 7 ++- .../get-besu-record-endpoint-v1.ts | 7 ++- .../web-services/get-block-v1-endpoint-.ts | 7 ++- .../web-services/get-past-logs-endpoint.ts | 7 ++- ...prometheus-exporter-metrics-endpoint-v1.ts | 33 +++++++--- .../web-services/get-transaction-endpoint.ts | 7 ++- .../web-services/invoke-contract-endpoint.ts | 7 ++- .../web-services/run-transaction-endpoint.ts | 7 ++- .../sign-transaction-endpoint-v1.ts | 33 +++++++--- .../deploy-contract/invoke-contract.test.ts | 12 ++-- .../openapi/openapi-validation.test.ts | 32 +++++----- .../web-services/get-lineage-v1-endpoint.ts | 13 ++-- .../register-history-data-v1-endpoint.ts | 12 ++-- ...earch-lineage-by-globaldata-v1-endpoint.ts | 12 ++-- .../search-lineage-by-header-v1-endpoint.ts | 13 ++-- .../deploy-contract-jars-endpoint.ts | 19 ++++-- .../web-services/diagnose-node-endpoint-v1.ts | 24 ++++--- ...prometheus-exporter-metrics-endpoint-v1.ts | 27 +++++--- .../invoke-contract-endpoint-v1.ts | 24 ++++--- .../web-services/list-flows-endpoint-v1.ts | 24 ++++--- .../web-services/network-map-endpoint-v1.ts | 24 ++++--- .../openapi/openapi-validation.test.ts | 15 ++--- .../plugin-ledger-connector-ethereum.ts | 38 ++++++------ ...prometheus-exporter-metrics-v1-endpoint.ts | 35 +++++++---- ...oy-and-invoke-using-json-object-v1.test.ts | 6 +- .../deploy-contract-endpoint-v1.ts | 26 +++----- .../get-block/get-block-endpoint-v1.ts | 16 ++--- ...prometheus-exporter-metrics-endpoint-v1.ts | 15 ++--- ...transaction-receipt-by-txid-endpoint-v1.ts | 15 ++--- .../plugin-ledger-connector-fabric.ts | 61 +++++++++++------- ...-delegated-sign-transaction-endpoint-v1.ts | 19 +++--- .../run-transaction-endpoint-v1.ts | 16 ++--- .../openapi/openapi-validation-go.test.ts | 4 +- .../openapi/openapi-validation.test.ts | 8 +-- .../generate-transaction-v1-endpoint.ts | 15 +++-- .../web-services/transact-v1-endpoint.ts | 12 ++-- ...nerate-and-send-signed-transaction.test.ts | 19 +++--- .../plugin-ledger-connector-polkadot.ts | 21 ++++--- .../plugin-ledger-connector-quorum.ts | 46 +++++++------- ...-solidity-bytecode-endpoint-json-object.ts | 5 +- ...prometheus-exporter-metrics-endpoint-v1.ts | 3 +- .../openapi-validation-no-keychain.test.ts | 8 +-- .../openapi/openapi-validation.test.ts | 12 ++-- .../web-services/status-endpoint-v1.ts | 12 ++-- ...loy-contract-solidity-bytecode-endpoint.ts | 3 +- ...-solidity-bytecode-json-object-endpoint.ts | 3 +- ...prometheus-exporter-metrics-endpoint-v1.ts | 3 +- .../integration/invoke-contract-xdai.test.ts | 2 +- .../openapi-validation-no-keychain.test.ts | 18 +++--- .../openapi/openapi-validation.test.ts | 12 ++-- .../web-services/status-endpoint-v1.ts | 12 ++-- .../client-side/client-request-endpoint.ts | 6 +- .../commit-final-response-endpoint.ts | 10 +-- .../commit-prepare-response-endpoint.ts | 13 ++-- .../lock-evidence-response-endpoint.ts | 12 ++-- .../transfer-commence-response-endpoint.ts | 10 +-- .../transfer-initiation-response-endpoint.ts | 13 ++-- .../recovery/recover-message-endpoint.ts | 10 +-- .../recover-success-message-endpoint.ts | 10 +-- .../recover-update-ack-message-endpoint.ts | 10 +-- .../recover-update-message-endpoint.ts | 10 +-- .../recovery/rollback-ack-message-endpoint.ts | 10 +-- .../recovery/rollback-message-endpoint.ts | 10 +-- .../commit-final-request-endpoint.ts | 10 +-- .../commite-prepare-request-endpoint.ts | 10 +-- .../lock-evidence-request-endpoint.ts | 10 +-- .../transfer-commence-request-endpoint.ts | 10 +-- .../transfer-complete-request-endpoint.ts | 10 +-- .../transfer-initiation-request-endpoint.ts | 13 ++-- .../openapi/openapi-validation.test.ts | 4 +- .../initialize-endpoint.test.ts | 2 +- .../new-contract-endpoint.test.ts | 2 +- .../openapi/openapi-validation.test.ts | 26 ++++---- .../refund-endpoint-invalid-time.test.ts | 2 +- .../refund-endpoint.test.ts | 2 +- .../withdraw-endpoint-invalid-id.test.ts | 2 +- ...get-single-status-endpoint-invalid.test.ts | 2 +- .../get-status-endpoint-invalid.test.ts | 2 +- .../openapi/openapi-validation.test.ts | 57 ++++++++++------- .../v21-sign-transaction-endpoint.test.ts | 2 +- .../fabric/fabric-test-ledger-v1.ts | 20 +++--- tools/generate-sbom.ts | 2 +- .../drivers/fabric-driver/server/server.ts | 6 +- 143 files changed, 1129 insertions(+), 768 deletions(-) diff --git a/examples/cactus-example-carbon-accounting-backend/src/test/typescript/integration/admin-enroll-v1-endpoint.test.ts b/examples/cactus-example-carbon-accounting-backend/src/test/typescript/integration/admin-enroll-v1-endpoint.test.ts index 9397d72b91e..8e9a48d4397 100644 --- a/examples/cactus-example-carbon-accounting-backend/src/test/typescript/integration/admin-enroll-v1-endpoint.test.ts +++ b/examples/cactus-example-carbon-accounting-backend/src/test/typescript/integration/admin-enroll-v1-endpoint.test.ts @@ -46,13 +46,13 @@ const log = LoggerProvider.getOrCreate({ level: logLevel, }); -interface ResponseError extends AxiosError { +interface ResponseError extends AxiosError { response: { - data: T; + data: any; status: number; statusText: string; - headers: any - config: any + headers: any; + config: any; request?: any; }; } @@ -194,7 +194,7 @@ test.skip(testCase, async (t: Test) => { await apiClientBad.enrollAdminV1({ orgName: "does-not-matter" }); t.fail("enroll admin response status === 403 FAIL"); } catch (err) { - const e = err as ResponseError + const e = err as ResponseError; t.ok(e, "error thrown for forbidden endpoint truthy OK"); t.ok(e.response, "enroll admin response truthy OK"); diff --git a/examples/cactus-example-discounted-asset-trade-client/src/main/typescript/scripts/run-discounted-asset-trade-client.ts b/examples/cactus-example-discounted-asset-trade-client/src/main/typescript/scripts/run-discounted-asset-trade-client.ts index e58f93e9a3c..fb0f742afb3 100644 --- a/examples/cactus-example-discounted-asset-trade-client/src/main/typescript/scripts/run-discounted-asset-trade-client.ts +++ b/examples/cactus-example-discounted-asset-trade-client/src/main/typescript/scripts/run-discounted-asset-trade-client.ts @@ -189,7 +189,12 @@ async function menuLoop(agent: AnoncredAgent) { break; } } catch (error) { - if (error && typeof error === 'object' && 'isTtyError' in error && error.isTtyError) { + if ( + error && + typeof error === "object" && + "isTtyError" in error && + error.isTtyError + ) { log.error("Prompt couldn't be rendered in the current environment:"); isRunning = false; } diff --git a/extensions/cactus-plugin-htlc-coordinator-besu/src/main/typescript/web-services/counterparty-htlc-endpoint.ts b/extensions/cactus-plugin-htlc-coordinator-besu/src/main/typescript/web-services/counterparty-htlc-endpoint.ts index 6b391c1c441..7250b6ee652 100644 --- a/extensions/cactus-plugin-htlc-coordinator-besu/src/main/typescript/web-services/counterparty-htlc-endpoint.ts +++ b/extensions/cactus-plugin-htlc-coordinator-besu/src/main/typescript/web-services/counterparty-htlc-endpoint.ts @@ -12,10 +12,10 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; import { PluginRegistry, + handleRestEndpointException, registerWebServiceEndpoint, } from "@hyperledger/cactus-core"; import { CounterpartyHTLCRequest } from "../generated/openapi/typescript-axios"; @@ -109,10 +109,8 @@ export class CounterpartyHTLCEndpoint implements IWebServiceEndpoint { res.json(resBody); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: ex, - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/extensions/cactus-plugin-htlc-coordinator-besu/src/main/typescript/web-services/own-htlc-endpoint.ts b/extensions/cactus-plugin-htlc-coordinator-besu/src/main/typescript/web-services/own-htlc-endpoint.ts index 85b6c47d87d..ea03bddb3dd 100644 --- a/extensions/cactus-plugin-htlc-coordinator-besu/src/main/typescript/web-services/own-htlc-endpoint.ts +++ b/extensions/cactus-plugin-htlc-coordinator-besu/src/main/typescript/web-services/own-htlc-endpoint.ts @@ -16,6 +16,7 @@ import { import { registerWebServiceEndpoint, PluginRegistry, + handleRestEndpointException, } from "@hyperledger/cactus-core"; import { PluginHTLCCoordinatorBesu } from "../plugin-htlc-coordinator-besu"; import { OwnHTLCRequest } from "../generated/openapi/typescript-axios"; @@ -103,10 +104,8 @@ export class OwnHTLCEndpoint implements IWebServiceEndpoint { res.json(resBody); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: ex, - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/get-object-endpoint-v1.ts b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/get-object-endpoint-v1.ts index 8f71e7c5f23..2f963f934b1 100644 --- a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/get-object-endpoint-v1.ts +++ b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/get-object-endpoint-v1.ts @@ -16,7 +16,10 @@ import { IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; @@ -93,10 +96,8 @@ export class GetObjectEndpointV1 implements IWebServiceEndpoint { res.json(resBody); } catch (ex) { this.log.error(`${tag} Failed to serve request:`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: ex, - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/has-object-endpoint-v1.ts b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/has-object-endpoint-v1.ts index 94998f2e998..2bfd49055d3 100644 --- a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/has-object-endpoint-v1.ts +++ b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/has-object-endpoint-v1.ts @@ -16,7 +16,10 @@ import { IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; @@ -93,10 +96,8 @@ export class HasObjectEndpointV1 implements IWebServiceEndpoint { res.json(resBody); } catch (ex) { this.log.error(`${tag} Failed to serve request:`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: ex, - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/set-object-endpoint-v1.ts b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/set-object-endpoint-v1.ts index fa05c369073..ca7bb3af9a3 100644 --- a/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/set-object-endpoint-v1.ts +++ b/extensions/cactus-plugin-object-store-ipfs/src/main/typescript/web-services/set-object-endpoint-v1.ts @@ -16,7 +16,10 @@ import { IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; @@ -93,10 +96,8 @@ export class SetObjectEndpointV1 implements IWebServiceEndpoint { res.json(resBody); } catch (ex) { this.log.error(`${tag} Failed to serve request:`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: ex, - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cacti-plugin-ledger-connector-stellar/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cacti-plugin-ledger-connector-stellar/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts index 2e23e0bb513..5bf38c8b39d 100644 --- a/packages/cacti-plugin-ledger-connector-stellar/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cacti-plugin-ledger-connector-stellar/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -1,6 +1,9 @@ import { Express, Request, Response } from "express"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; @@ -26,8 +29,7 @@ export interface IGetPrometheusExporterMetricsEndpointV1Options { } export class GetPrometheusExporterMetricsEndpointV1 - implements IWebServiceEndpoint -{ + implements IWebServiceEndpoint { private readonly log: Logger; constructor( @@ -94,9 +96,8 @@ export class GetPrometheusExporterMetricsEndpointV1 res.send(resBody); } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); - res.status(500); - res.statusMessage = ex.message; - res.json({ error: ex.stack }); + const errorMsg = `Internal server Error`; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-api-client/src/test/typescript/integration/default-consortium-provider.test.ts b/packages/cactus-api-client/src/test/typescript/integration/default-consortium-provider.test.ts index 417d5254b93..3be869825d4 100644 --- a/packages/cactus-api-client/src/test/typescript/integration/default-consortium-provider.test.ts +++ b/packages/cactus-api-client/src/test/typescript/integration/default-consortium-provider.test.ts @@ -32,18 +32,23 @@ test("Reports failures with meaningful information", async (t: Test) => { await provider.get(); t2.fail("Provider.get() did not throw despite API errors."); } catch (ex) { - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && typeof ex.message === 'string') { - t2.ok(ex, "Thrown error truthy OK"); - t2.ok(ex.message, "Thrown error.message truthy OK"); - t2.equal( - typeof ex.message, - "string", - "Thrown error.message type string OK", - ); - t2.true(ex.message.includes("timeout"), "Has timeout in msg OK"); - } - } else { t2.ok(ex, "Thrown error truthy OK"); } + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + typeof ex.message === "string" + ) { + t2.ok(ex, "Thrown error truthy OK"); + t2.ok(ex.message, "Thrown error.message truthy OK"); + t2.equal( + typeof ex.message, + "string", + "Thrown error.message type string OK", + ); + t2.true(ex.message.includes("timeout"), "Has timeout in msg OK"); + } else { + t2.ok(ex, "Thrown error truthy OK"); + } } t2.end(); }); @@ -61,9 +66,8 @@ test("Reports failures with meaningful information", async (t: Test) => { await provider.get(); t2.fail("Provider.get() did not throw despite API errors."); } catch (ex) { - - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && typeof ex.message === 'string') { + if (typeof ex === "object" && ex !== null) { + if ("message" in ex && typeof ex.message === "string") { t2.ok(ex, "Thrown error truthy OK"); t2.ok(ex.message, "Thrown error.message truthy OK"); t2.equal( @@ -76,8 +80,9 @@ test("Reports failures with meaningful information", async (t: Test) => { "Has Status Code in msg OK", ); } - } else { t2.ok(ex, "Thrown error truthy OK"); } - + } else { + t2.ok(ex, "Thrown error truthy OK"); + } } t2.end(); }); diff --git a/packages/cactus-cmd-api-server/src/main/typescript/web-services/watch-healthcheck-v1-endpoint.ts b/packages/cactus-cmd-api-server/src/main/typescript/web-services/watch-healthcheck-v1-endpoint.ts index a60035e92f0..c56fe044ed3 100644 --- a/packages/cactus-cmd-api-server/src/main/typescript/web-services/watch-healthcheck-v1-endpoint.ts +++ b/packages/cactus-cmd-api-server/src/main/typescript/web-services/watch-healthcheck-v1-endpoint.ts @@ -4,7 +4,6 @@ import { Logger, Checks } from "@hyperledger/cactus-common"; import { LogLevelDesc, LoggerProvider } from "@hyperledger/cactus-common"; import { HealthCheckResponse } from "../generated/openapi/typescript-axios"; import { WatchHealthcheckV1 } from "../generated/openapi/typescript-axios"; -import { response } from "express"; export interface IWatchHealthcheckV1EndpointOptions { logLevel?: LogLevelDesc; @@ -54,7 +53,7 @@ export class WatchHealthcheckV1Endpoint { socket.emit(WatchHealthcheckV1.Next, next); } catch (ex) { log.error(`Failed to construct health check response:`, ex); - let responseError = ex as HealthCheckResponse + const responseError = ex as HealthCheckResponse; socket.emit(WatchHealthcheckV1.Error, responseError); clearInterval(timerId); } diff --git a/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/deploy-contract-endpoint.ts b/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/deploy-contract-endpoint.ts index 56ca7e6b19e..806d0374b5a 100644 --- a/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/deploy-contract-endpoint.ts +++ b/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/deploy-contract-endpoint.ts @@ -12,10 +12,12 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorStub } from "../plugin-ledger-connector-stub"; @@ -102,10 +104,8 @@ export class DeployContractEndpoint implements IWebServiceEndpoint { res.json(resBody); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/run-transaction-endpoint.ts b/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/run-transaction-endpoint.ts index ca1bed8c006..957ad943e14 100644 --- a/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/run-transaction-endpoint.ts +++ b/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/run-transaction-endpoint.ts @@ -6,14 +6,16 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; import { IEndpointAuthzOptions, IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorStub } from "../plugin-ledger-connector-stub"; @@ -100,10 +102,8 @@ export class RunTransactionEndpoint implements IWebServiceEndpoint { res.json({ success: true, data: resBody }); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/unprotected-action-endpoint.ts b/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/unprotected-action-endpoint.ts index dbd693da78a..4f6de7afeb8 100644 --- a/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/unprotected-action-endpoint.ts +++ b/packages/cactus-cmd-api-server/src/test/typescript/fixtures/plugin-ledger-connector-stub/web-services/unprotected-action-endpoint.ts @@ -6,14 +6,16 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; import { IEndpointAuthzOptions, IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorStub } from "../plugin-ledger-connector-stub"; @@ -106,10 +108,8 @@ export class UnprotectedActionEndpoint implements IWebServiceEndpoint { res.json({ success: true, data }); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/routes/login.ts b/packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/routes/login.ts index fdd0f57fef6..5dd51978891 100644 --- a/packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/routes/login.ts +++ b/packages/cactus-cmd-socketio-server/src/main/typescript/routing-interface/routes/login.ts @@ -46,11 +46,9 @@ router.post("/", (req: Request, res: Response, next: NextFunction) => { res.status(201); res.send(respData); } catch (err) { - - if (typeof err === 'object' && err !== null) { logger.error(`##err name: ${err.constructor.name}`); } - - - + if (typeof err === "object" && err !== null) { + logger.error(`##err name: ${err.constructor.name}`); + } if (err instanceof RIFError) { logger.debug(`##catch RIFError, ${err.statusCode}, ${err.message}`); diff --git a/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-consortium-jws-endpoint-v1.ts b/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-consortium-jws-endpoint-v1.ts index ae017298a1f..8616f510ab8 100644 --- a/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-consortium-jws-endpoint-v1.ts +++ b/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-consortium-jws-endpoint-v1.ts @@ -112,9 +112,7 @@ export class GetConsortiumEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - - + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-node-jws-endpoint-v1.ts b/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-node-jws-endpoint-v1.ts index a7d1c4f32ef..0398ab4e585 100644 --- a/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-node-jws-endpoint-v1.ts +++ b/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-node-jws-endpoint-v1.ts @@ -108,7 +108,7 @@ export class GetNodeJwsEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-prometheus-exporter-metrics-endpoint-v1.ts index 497b69acb39..37b72b8e254 100644 --- a/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-consortium-manual/src/main/typescript/consortium/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -16,7 +16,10 @@ import { import OAS from "../../json/openapi.json"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginConsortiumManual } from "../plugin-consortium-manual"; @@ -26,7 +29,8 @@ export interface IGetPrometheusExporterMetricsEndpointV1Options { } export class GetPrometheusExporterMetricsEndpointV1 - implements IWebServiceEndpoint { + implements IWebServiceEndpoint +{ private readonly log: Logger; constructor( @@ -95,7 +99,7 @@ export class GetPrometheusExporterMetricsEndpointV1 } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-single-status-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-single-status-endpoint.ts index d0d0adae8e9..91f09ea1007 100644 --- a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-single-status-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-single-status-endpoint.ts @@ -11,7 +11,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginHtlcEthBesuErc20 } from "../plugin-htlc-eth-besu-erc20"; @@ -86,7 +89,7 @@ export class GetSingleStatusEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); const errorMsg = `Bad request`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-status-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-status-endpoint.ts index de5849019fc..3e8e563604f 100644 --- a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-status-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/get-status-endpoint.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginHtlcEthBesuErc20 } from "../plugin-htlc-eth-besu-erc20"; @@ -86,7 +89,7 @@ export class GetStatusEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); const errorMsg = `Bar request`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/initialize-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/initialize-endpoint.ts index f2938b30d06..7cdac1e4a49 100644 --- a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/initialize-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/initialize-endpoint.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { InitializeRequest } from "../generated/openapi/typescript-axios"; @@ -90,7 +93,7 @@ export class InitializeEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); const errorMsg = `Bad request`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/new-contract-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/new-contract-endpoint.ts index 84edffee57a..91ba2c6f9af 100644 --- a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/new-contract-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/new-contract-endpoint.ts @@ -11,7 +11,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { NewContractRequest } from "../generated/openapi/typescript-axios"; import OAS from "../../json/openapi.json"; import { PluginHtlcEthBesuErc20 } from "../plugin-htlc-eth-besu-erc20"; @@ -86,7 +89,7 @@ export class NewContractEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); const errorMsg = `Bad request`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/refund-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/refund-endpoint.ts index 5811385650a..242da44d546 100644 --- a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/refund-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/refund-endpoint.ts @@ -11,7 +11,10 @@ import { IWebServiceEndpoint, IEndpointAuthzOptions, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { RefundRequest } from "../generated/openapi/typescript-axios"; import OAS from "../../json/openapi.json"; import { PluginHtlcEthBesuErc20 } from "../plugin-htlc-eth-besu-erc20"; @@ -86,7 +89,7 @@ export class RefundEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); const errorMsg = `Bad request`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/withdraw-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/withdraw-endpoint.ts index 160c30b60d6..fef65ae2467 100644 --- a/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/withdraw-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu-erc20/src/main/typescript/web-services/withdraw-endpoint.ts @@ -11,7 +11,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { WithdrawRequest } from "../generated/openapi/typescript-axios"; import OAS from "../../json/openapi.json"; import { PluginHtlcEthBesuErc20 } from "../plugin-htlc-eth-besu-erc20"; @@ -86,7 +89,7 @@ export class WithdrawEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); const errorMsg = `Bad request`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-single-status-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-single-status-endpoint.ts index eda2602f96e..170520f8493 100644 --- a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-single-status-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-single-status-endpoint.ts @@ -11,7 +11,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginHtlcEthBesu } from "../plugin-htlc-eth-besu"; import OAS from "../../json/openapi.json"; @@ -94,7 +97,7 @@ export class GetSingleStatusEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-status-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-status-endpoint.ts index 13d46f985f2..e96dfe83445 100644 --- a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-status-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/get-status-endpoint.ts @@ -11,7 +11,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginHtlcEthBesu } from "../plugin-htlc-eth-besu"; export interface IGetStatusEndpointOptions { @@ -90,9 +93,9 @@ export class GetStatusEndpoint implements IWebServiceEndpoint { res.send(callOutput); } } catch (ex) { - this.log.error(`${fnTag} failed to serve request`, ex); + this.log.error(`${fnTag} request handler fn crashed for: ${reqTag}`, ex); const errorMsg = `Internal server error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/initialize-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/initialize-endpoint.ts index 8c21ff11eee..c60b5f2ad7d 100644 --- a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/initialize-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/initialize-endpoint.ts @@ -11,7 +11,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { InitializeRequest } from "../generated/openapi/typescript-axios"; @@ -94,9 +97,9 @@ export class InitializeEndpoint implements IWebServiceEndpoint { res.send(result); } } catch (ex) { - this.log.error(`${fnTag} failed to serve request`, ex); + this.log.error(`${fnTag} request handler fn crashed for: ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/new-contract-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/new-contract-endpoint.ts index 4581afde9d9..51b0b7d07e4 100644 --- a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/new-contract-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/new-contract-endpoint.ts @@ -11,7 +11,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { NewContractObj } from "../generated/openapi/typescript-axios/api"; import { PluginHtlcEthBesu } from "../plugin-htlc-eth-besu"; import OAS from "../../json/openapi.json"; @@ -92,9 +95,9 @@ export class NewContractEndpoint implements IWebServiceEndpoint { res.send(result); } } catch (ex) { - this.log.error(`${fnTag} failed to serve request`, ex); - const errorMsg = "Internal server Error" - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + this.log.error(`${fnTag} request handler fn crashed for: ${reqTag}`, ex); + const errorMsg = "Internal server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/refund-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/refund-endpoint.ts index 021b47a6770..34d11128aa8 100644 --- a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/refund-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/refund-endpoint.ts @@ -11,7 +11,10 @@ import { IWebServiceEndpoint, IEndpointAuthzOptions, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginHtlcEthBesu } from "../plugin-htlc-eth-besu"; import { RefundReq } from "../generated/openapi/typescript-axios"; import OAS from "../../json/openapi.json"; @@ -93,7 +96,7 @@ export class RefundEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); const errorMsg = "Internal server Error"; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/withdraw-endpoint.ts b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/withdraw-endpoint.ts index cfefba6e459..6608155a08a 100644 --- a/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/withdraw-endpoint.ts +++ b/packages/cactus-plugin-htlc-eth-besu/src/main/typescript/web-services/withdraw-endpoint.ts @@ -11,7 +11,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginHtlcEthBesu } from "../plugin-htlc-eth-besu"; import { WithdrawReq } from "../generated/openapi/typescript-axios/api"; import OAS from "../../json/openapi.json"; @@ -92,7 +95,7 @@ export class WithdrawEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/delete-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/delete-keychain-entry-endpoint-v1.ts index 9e43562c3bc..fcd745a5dce 100644 --- a/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/delete-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/delete-keychain-entry-endpoint-v1.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginKeychainAwsSm } from "../plugin-keychain-aws-sm"; @@ -94,7 +97,7 @@ export class DeleteKeychainEntryV1Endpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/get-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/get-keychain-entry-endpoint-v1.ts index 6a0a755b88a..1195938b891 100644 --- a/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/get-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/get-keychain-entry-endpoint-v1.ts @@ -13,7 +13,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginKeychainAwsSm } from "../plugin-keychain-aws-sm"; @@ -93,17 +96,30 @@ export class GetKeychainEntryV1Endpoint implements IWebServiceEndpoint { //const resBody = await this.options.connector.get(reqBody.key); res.json({ key, value }); } catch (ex) { - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && typeof ex.message === 'string') { - if (ex?.message?.includes(`${key} secret not found`)) { - const errorMsg = ex.message - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - } + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + typeof ex.message === "string" + ) { + if (ex?.message?.includes(`${key} secret not found`)) { + const errorMsg = ex.message; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } } else { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } } } diff --git a/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/get-prometheus-exporter-metrics-endpoint-v1.ts index 88501944ca8..09889d93eab 100644 --- a/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -16,7 +16,10 @@ import { import OAS from "../../json/openapi.json"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginKeychainAwsSm } from "../plugin-keychain-aws-sm"; @@ -93,16 +96,28 @@ export class GetPrometheusExporterMetricsEndpointV1 res.send(resBody); } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && typeof ex.message === 'string') { - const errorMsg = ex.message - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - } + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + typeof ex.message === "string" + ) { + const errorMsg = ex.message; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } else { const errorMsg = `Bar request`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } - } } } diff --git a/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/has-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/has-keychain-entry-endpoint-v1.ts index be3013c9aac..27beb90d514 100644 --- a/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/has-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/has-keychain-entry-endpoint-v1.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginKeychainAwsSm } from "../plugin-keychain-aws-sm"; @@ -100,7 +103,7 @@ export class HasKeychainEntryV1Endpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error}`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/set-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/set-keychain-entry-endpoint-v1.ts index 18fa452f47f..1ec082680d8 100644 --- a/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/set-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-aws-sm/src/main/typescript/webservices/set-keychain-entry-endpoint-v1.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginKeychainAwsSm } from "../plugin-keychain-aws-sm"; @@ -93,7 +96,7 @@ export class SetKeychainEntryV1Endpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-aws-sm/src/test/typescript/integration/openapi/openapi-validation.test.ts b/packages/cactus-plugin-keychain-aws-sm/src/test/typescript/integration/openapi/openapi-validation.test.ts index b31a50dff3e..024dc350a09 100644 --- a/packages/cactus-plugin-keychain-aws-sm/src/test/typescript/integration/openapi/openapi-validation.test.ts +++ b/packages/cactus-plugin-keychain-aws-sm/src/test/typescript/integration/openapi/openapi-validation.test.ts @@ -147,10 +147,9 @@ describe("PluginKeychainAwsSm", () => { value, } as any as SetKeychainEntryRequestV1); } catch (e: any) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fSet} without required key: response.status === 400 OK`, + expect(e.response.status).toEqual(400); + console.log( + `Endpoint ${fDelete} without required key: response.status === 400 OK`, ); const fields = e.response.data.map((param: any) => param.path.replace("/body/", ""), @@ -165,10 +164,9 @@ describe("PluginKeychainAwsSm", () => { {} as any as GetKeychainEntryRequestV1, ); } catch (e: any) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fGet} without required key: response.status === 400 OK`, + expect(e.response.status).toEqual(400); + console.log( + `Endpoint ${fDelete} without required key: response.status === 400 OK`, ); const fields = e.response.data.map((param: any) => param.path.replace("/body/", ""), @@ -183,10 +181,9 @@ describe("PluginKeychainAwsSm", () => { {} as any as HasKeychainEntryRequestV1, ); } catch (e: any) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fHas} without required key: response.status === 400 OK`, + expect(e.response.status).toEqual(400); + console.log( + `Endpoint ${fDelete} without required key: response.status === 400 OK`, ); const fields = e.response.data.map((param: any) => param.path.replace("/body/", ""), @@ -201,11 +198,11 @@ describe("PluginKeychainAwsSm", () => { {} as any as DeleteKeychainEntryRequestV1, ); } catch (e: any) { - t2.equal( - e.response.status, - 400, + expect(e.response.status).toEqual(400); + console.log( `Endpoint ${fDelete} without required key: response.status === 400 OK`, ); + const fields = e.response.data.map((param: any) => param.path.replace("/body/", ""), ); @@ -221,10 +218,9 @@ describe("PluginKeychainAwsSm", () => { fake: 4, } as any as SetKeychainEntryRequestV1); } catch (e: any) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fSet} with fake=4: response.status === 400 OK`, + expect(e.response.status).toEqual(400); + console.log( + `Endpoint ${fDelete} with fake = 4: response.status === 400 OK`, ); const fields = e.response.data.map((param: any) => param.path.replace("/body/", ""), @@ -233,17 +229,16 @@ describe("PluginKeychainAwsSm", () => { } }); - test(`${testCase} - ${fGet} - ${cInvalidParams}`, async () => { + test(`${testCase} - ${fGet} - ${cInvalidParams} `, async () => { try { await apiClient.getKeychainEntryV1({ key, fake: 4, } as any as GetKeychainEntryRequestV1); } catch (e: any) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fGet} with fake=4: response.status === 400 OK`, + expect(e.response.status).toEqual(400); + console.log( + `Endpoint ${fDelete} with fake = 4: response.status === 400 OK`, ); const fields = e.response.data.map((param: any) => param.path.replace("/body/", ""), @@ -252,17 +247,16 @@ describe("PluginKeychainAwsSm", () => { } }); - test(`${testCase} - ${fHas} - ${cInvalidParams}`, async () => { + test(`${testCase} - ${fHas} - ${cInvalidParams} `, async () => { try { await apiClient.hasKeychainEntryV1({ key, fake: 4, } as any as HasKeychainEntryRequestV1); } catch (e: any) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fHas} with fake=4: response.status === 400 OK`, + expect(e.response.status).toEqual(400); + console.log( + `Endpoint ${fDelete} with fake = 4: response.status === 400 OK`, ); const fields = e.response.data.map((param: any) => param.path.replace("/body/", ""), @@ -271,18 +265,18 @@ describe("PluginKeychainAwsSm", () => { } }); - test(`${testCase} - ${fDelete} - ${cInvalidParams}`, async () => { + test(`${testCase} - ${fDelete} - ${cInvalidParams} `, async () => { try { await apiClient.deleteKeychainEntryV1({ key, fake: 4, } as any as DeleteKeychainEntryRequestV1); } catch (e: any) { - t2.equal( - e.response.status, - 400, - `Endpoint ${fDelete} with fake=4: response.status === 400 OK`, + expect(e.response.status).toEqual(400); + console.log( + `Endpoint ${fDelete} with fake = 4: response.status === 400 OK`, ); + const fields = e.response.data.map((param: any) => param.path.replace("/body/", ""), ); diff --git a/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/delete-keychain-entry-endpoint.ts b/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/delete-keychain-entry-endpoint.ts index bf472bb41f4..2fbcb52b228 100644 --- a/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/delete-keychain-entry-endpoint.ts +++ b/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/delete-keychain-entry-endpoint.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginKeychainAzureKv } from "../plugin-keychain-azure-kv"; @@ -94,7 +97,7 @@ export class DeleteKeychainEntryEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/get-keychain-entry-endpoint.ts b/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/get-keychain-entry-endpoint.ts index 99d9f2a46c4..b6c94da0931 100644 --- a/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/get-keychain-entry-endpoint.ts +++ b/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/get-keychain-entry-endpoint.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginKeychainAzureKv } from "../plugin-keychain-azure-kv"; @@ -95,17 +98,29 @@ export class GetKeychainEntryEndpoint implements IWebServiceEndpoint { value, }); } catch (ex) { - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && typeof ex.message === 'string') { - if (ex?.message?.includes(`${key} secret not found`)) { - const errorMsg = ex.message - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - } - } + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + typeof ex.message === "string" && + ex?.message?.includes(`${key} secret not found`) + ) { + const errorMsg = ex.message; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } else { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } } } diff --git a/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/has-keychain-entry-endpoint.ts b/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/has-keychain-entry-endpoint.ts index 159a4b26cbc..c0c87892e6e 100644 --- a/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/has-keychain-entry-endpoint.ts +++ b/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/has-keychain-entry-endpoint.ts @@ -14,7 +14,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginKeychainAzureKv } from "../plugin-keychain-azure-kv"; @@ -102,7 +105,7 @@ export class HasKeychainEntryEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/set-keychain-entry-endpoint.ts b/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/set-keychain-entry-endpoint.ts index 67f62a3ce35..23c4faa678a 100644 --- a/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/set-keychain-entry-endpoint.ts +++ b/packages/cactus-plugin-keychain-azure-kv/src/main/typescript/web-services/set-keychain-entry-endpoint.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginKeychainAzureKv } from "../plugin-keychain-azure-kv"; @@ -94,7 +97,7 @@ export class SetKeychainEntryEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/delete-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/delete-keychain-entry-endpoint-v1.ts index 6053028f7d3..20e00f5bf35 100644 --- a/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/delete-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/delete-keychain-entry-endpoint-v1.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginKeychainGoogleSm } from "../plugin-keychain-google-sm"; @@ -92,7 +95,7 @@ export class DeleteKeychainEntryV1Endpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/get-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/get-keychain-entry-endpoint-v1.ts index 04225a2a794..b61faaa4c74 100644 --- a/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/get-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/get-keychain-entry-endpoint-v1.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginKeychainGoogleSm } from "../plugin-keychain-google-sm"; @@ -90,16 +93,29 @@ export class GetKeychainEntryV1Endpoint implements IWebServiceEndpoint { const resBody = await this.options.connector.get(reqBody.key); res.json(resBody); } catch (ex) { - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && ex['message'] && typeof ex.message === 'string') { - const errorMsg = ex.message - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - } - } - else { + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + ex["message"] && + typeof ex.message === "string" + ) { + const errorMsg = ex.message; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); + } else { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } } } diff --git a/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/has-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/has-keychain-entry-endpoint-v1.ts index bf417e3c4c3..1410bfc671a 100644 --- a/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/has-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/has-keychain-entry-endpoint-v1.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginKeychainGoogleSm } from "../plugin-keychain-google-sm"; @@ -94,7 +97,7 @@ export class HasKeychainEntryV1Endpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/set-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/set-keychain-entry-endpoint-v1.ts index 8eed0229f8e..2d95bde825b 100644 --- a/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/set-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-google-sm/src/main/typescript/webservices/set-keychain-entry-endpoint-v1.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginKeychainGoogleSm } from "../plugin-keychain-google-sm"; @@ -94,8 +97,8 @@ export class SetKeychainEntryV1Endpoint implements IWebServiceEndpoint { res.json(resBody); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - const errorMsg = `Internal server Erorr`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + const errorMsg = `Internal server Error`; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-google-sm/src/test/typescript/integration/openapi/openapi-validation.test.ts b/packages/cactus-plugin-keychain-google-sm/src/test/typescript/integration/openapi/openapi-validation.test.ts index d89b12a9095..fb7683444d2 100644 --- a/packages/cactus-plugin-keychain-google-sm/src/test/typescript/integration/openapi/openapi-validation.test.ts +++ b/packages/cactus-plugin-keychain-google-sm/src/test/typescript/integration/openapi/openapi-validation.test.ts @@ -114,7 +114,7 @@ test(testCase, async (t: Test) => { value, } as any as SetKeychainEntryRequestV1); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -134,7 +134,7 @@ test(testCase, async (t: Test) => { {} as any as GetKeychainEntryRequestV1, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -154,7 +154,7 @@ test(testCase, async (t: Test) => { {} as any as HasKeychainEntryRequestV1, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -174,7 +174,7 @@ test(testCase, async (t: Test) => { {} as any as DeleteKeychainEntryRequestV1, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -196,7 +196,7 @@ test(testCase, async (t: Test) => { fake: 4, } as any as SetKeychainEntryRequestV1); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -220,7 +220,7 @@ test(testCase, async (t: Test) => { fake: 4, } as any as GetKeychainEntryRequestV1); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -244,7 +244,7 @@ test(testCase, async (t: Test) => { fake: 4, } as any as HasKeychainEntryRequestV1); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -268,7 +268,7 @@ test(testCase, async (t: Test) => { fake: 4, } as any as DeleteKeychainEntryRequestV1); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, diff --git a/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/delete-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/delete-keychain-entry-endpoint-v1.ts index 783b9d29842..c29191c1d6e 100644 --- a/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/delete-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/delete-keychain-entry-endpoint-v1.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { DeleteKeychainEntryRequestV1 } from "@hyperledger/cactus-core-api"; import OAS from "../../json/openapi.json"; @@ -93,7 +96,7 @@ export class DeleteKeychainEntryV1Endpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/get-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/get-keychain-entry-endpoint-v1.ts index 2ec2b932263..1a2f2de6235 100644 --- a/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/get-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/get-keychain-entry-endpoint-v1.ts @@ -13,7 +13,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginKeychainMemoryWasm } from "../plugin-keychain-memory-wasm"; @@ -91,16 +94,29 @@ export class GetKeychainEntryV1Endpoint implements IWebServiceEndpoint { const value = await this.options.plugin.get(key); res.json({ key, value }); } catch (ex) { - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && ex['message'] && typeof ex.message === 'string') { - const errorMsg = ex.message - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - } - + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + ex["message"] && + typeof ex.message === "string" + ) { + const errorMsg = ex.message; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } else { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } } } diff --git a/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/has-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/has-keychain-entry-endpoint-v1.ts index c649dd3c376..394a7bfdcba 100644 --- a/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/has-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/has-keychain-entry-endpoint-v1.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginKeychainMemoryWasm } from "../plugin-keychain-memory-wasm"; @@ -100,7 +103,7 @@ export class HasKeychainEntryV1Endpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/set-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/set-keychain-entry-endpoint-v1.ts index 61ec64dad16..eda27080b84 100644 --- a/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/set-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-memory-wasm/src/main/typescript/webservices/set-keychain-entry-endpoint-v1.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginKeychainMemoryWasm } from "../plugin-keychain-memory-wasm"; @@ -93,7 +96,7 @@ export class SetKeychainEntryV1Endpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-memory/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-keychain-memory/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts index d745e6e789b..c3d041bc30f 100644 --- a/packages/cactus-plugin-keychain-memory/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-memory/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -16,7 +16,10 @@ import { import OAS from "../../json/openapi.json"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginKeychainMemory } from "../plugin-keychain-memory"; @@ -26,7 +29,8 @@ export interface IGetPrometheusExporterMetricsEndpointV1Options { } export class GetPrometheusExporterMetricsEndpointV1 - implements IWebServiceEndpoint { + implements IWebServiceEndpoint +{ private readonly log: Logger; constructor( @@ -83,7 +87,6 @@ export class GetPrometheusExporterMetricsEndpointV1 } async handleRequest(req: Request, res: Response): Promise { - const fnTag = "GetPrometheusExporterMetrics#handleRequest()"; const verbUpper = this.getVerbLowerCase().toUpperCase(); this.log.debug(`${verbUpper} ${this.getPath()}`); @@ -92,14 +95,28 @@ export class GetPrometheusExporterMetricsEndpointV1 res.status(200); res.send(resBody); } catch (ex) { - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && ex['message'] && typeof ex.message === 'string') { - const errorMsg = ex.message - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - } + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + ex["message"] && + typeof ex.message === "string" + ) { + const errorMsg = ex.message; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } else { - const errorMsg = '' - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + const errorMsg = ""; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } } } diff --git a/packages/cactus-plugin-keychain-vault/src/main/typescript/plugin-keychain-vault.ts b/packages/cactus-plugin-keychain-vault/src/main/typescript/plugin-keychain-vault.ts index 3ec4b5712e8..ca3699f67dd 100644 --- a/packages/cactus-plugin-keychain-vault/src/main/typescript/plugin-keychain-vault.ts +++ b/packages/cactus-plugin-keychain-vault/src/main/typescript/plugin-keychain-vault.ts @@ -1,7 +1,7 @@ import type { Express } from "express"; import Vault from "node-vault"; import HttpStatus from "http-status-codes"; -import handleVaultResponse from "node-vault" +import handleVaultResponse from "node-vault"; import OAS from "../json/openapi.json"; import { @@ -255,10 +255,11 @@ export class PluginKeychainVault implements IPluginWebService, IPluginKeychain { const path = this.pathFor(key); try { const res = await this.backend.read(path); - return res; `` + return res; + ``; } catch (ex) { const errorResponse = ex as ErrorResponse; - handleVaultResponse() + handleVaultResponse(); // We have to make sure that the exception is either an expected // or an unexpected one where the expected exception is `what we // get when the key is not present in the keychain and anything diff --git a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/delete-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/delete-keychain-entry-endpoint-v1.ts index 28da671dd71..7c6f46d68ad 100644 --- a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/delete-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/delete-keychain-entry-endpoint-v1.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginKeychainVault } from "../plugin-keychain-vault"; @@ -103,7 +106,7 @@ export class DeleteKeychainEntryEndpointV1 implements IWebServiceEndpoint { this.log.debug(`${tag} Failed to serve request:`, ex); res.status(500); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-keychain-entry-endpoint-v1.ts index 17f136545f2..fd713625b87 100644 --- a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-keychain-entry-endpoint-v1.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginKeychainVault } from "../plugin-keychain-vault"; @@ -103,7 +106,7 @@ export class GetKeychainEntryEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.debug(`${tag} Failed to serve request:`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts index 7a62fa9bb62..41476f384e4 100644 --- a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -16,7 +16,10 @@ import { import OAS from "../../json/openapi.json"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginKeychainVault } from "../plugin-keychain-vault"; @@ -26,7 +29,8 @@ export interface IGetPrometheusExporterMetricsEndpointV1Options { } export class GetPrometheusExporterMetricsEndpointV1 - implements IWebServiceEndpoint { + implements IWebServiceEndpoint +{ private readonly log: Logger; constructor( @@ -94,7 +98,7 @@ export class GetPrometheusExporterMetricsEndpointV1 } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/has-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/has-keychain-entry-endpoint-v1.ts index d8e4b7b2c8e..b9e14d7af50 100644 --- a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/has-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/has-keychain-entry-endpoint-v1.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginKeychainVault } from "../plugin-keychain-vault"; @@ -104,7 +107,7 @@ export class HasKeychainEntryEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.debug(`${tag} Failed to serve request:`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/set-keychain-entry-endpoint-v1.ts b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/set-keychain-entry-endpoint-v1.ts index cfd1cd681db..acc2de7005c 100644 --- a/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/set-keychain-entry-endpoint-v1.ts +++ b/packages/cactus-plugin-keychain-vault/src/main/typescript/web-services/set-keychain-entry-endpoint-v1.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginKeychainVault } from "../plugin-keychain-vault"; @@ -98,7 +101,7 @@ export class SetKeychainEntryEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.debug(`${tag} Failed to serve request:`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/accept-invitation-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/accept-invitation-v1-endpoint.ts index 123d8edc18f..78642755879 100644 --- a/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/accept-invitation-v1-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/accept-invitation-v1-endpoint.ts @@ -11,9 +11,11 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorAries } from "../plugin-ledger-connector-aries"; import OAS from "../../json/openapi.json"; @@ -93,11 +95,8 @@ export class AcceptInvitationEndpoint implements IWebServiceEndpoint { ); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/create-new-connection-invitation-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/create-new-connection-invitation-v1-endpoint.ts index f2805929bf8..bf023ad58ac 100644 --- a/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/create-new-connection-invitation-v1-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/create-new-connection-invitation-v1-endpoint.ts @@ -11,9 +11,11 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorAries } from "../plugin-ledger-connector-aries"; import OAS from "../../json/openapi.json"; @@ -24,8 +26,7 @@ export interface ICreateNewConnectionInvitationOptions { } export class CreateNewConnectionInvitationEndpoint - implements IWebServiceEndpoint -{ + implements IWebServiceEndpoint { private readonly log: Logger; public get className(): string { @@ -95,11 +96,8 @@ export class CreateNewConnectionInvitationEndpoint ); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/get-agents-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/get-agents-v1-endpoint.ts index 5d896b83541..7ae22cccc78 100644 --- a/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/get-agents-v1-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/get-agents-v1-endpoint.ts @@ -11,9 +11,11 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorAries } from "../plugin-ledger-connector-aries"; import OAS from "../../json/openapi.json"; @@ -86,11 +88,8 @@ export class GetAgentsEndpoint implements IWebServiceEndpoint { res.status(200).json(await this.options.connector.getAgents()); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/get-connections-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/get-connections-v1-endpoint.ts index bd234740546..d37da3540ab 100644 --- a/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/get-connections-v1-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/get-connections-v1-endpoint.ts @@ -11,9 +11,11 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorAries } from "../plugin-ledger-connector-aries"; import OAS from "../../json/openapi.json"; @@ -93,11 +95,8 @@ export class GetConnectionsEndpoint implements IWebServiceEndpoint { ); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/request-proof-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/request-proof-v1-endpoint.ts index 948e894ec2d..c4c834da5f0 100644 --- a/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/request-proof-v1-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-aries/src/main/typescript/web-services/request-proof-v1-endpoint.ts @@ -11,9 +11,11 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorAries } from "../plugin-ledger-connector-aries"; import OAS from "../../json/openapi.json"; @@ -94,11 +96,8 @@ export class RequestProofEndpoint implements IWebServiceEndpoint { ); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-balance-endpoint.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-balance-endpoint.ts index ce391e51760..3ee2616d6ed 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-balance-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-balance-endpoint.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorBesu } from "../plugin-ledger-connector-besu"; @@ -91,7 +94,7 @@ export class GetBalanceEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-besu-record-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-besu-record-endpoint-v1.ts index 695354990a2..8a68fa65036 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-besu-record-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-besu-record-endpoint-v1.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorBesu } from "../plugin-ledger-connector-besu"; import { GetBesuRecordV1Request } from "../generated/openapi/typescript-axios/api"; @@ -95,7 +98,7 @@ export class GetBesuRecordEndpointV1 implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-block-v1-endpoint-.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-block-v1-endpoint-.ts index 93d4fc0fc4b..192184443be 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-block-v1-endpoint-.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-block-v1-endpoint-.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorBesu } from "../plugin-ledger-connector-besu"; @@ -91,7 +94,7 @@ export class GetBlockEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-past-logs-endpoint.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-past-logs-endpoint.ts index b200800c671..68c0590ab04 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-past-logs-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-past-logs-endpoint.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorBesu } from "../plugin-ledger-connector-besu"; @@ -91,7 +94,7 @@ export class GetPastLogsEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts index 151a3ad738e..c192ec2deb1 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -1,6 +1,9 @@ import { Express, Request, Response } from "express"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; @@ -94,16 +97,28 @@ export class GetPrometheusExporterMetricsEndpointV1 res.send(resBody); } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && typeof ex.message === 'string') { - const errorMsg = ex.message - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - } - } - else { + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + typeof ex.message === "string" + ) { + const errorMsg = ex.message; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); + } else { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-transaction-endpoint.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-transaction-endpoint.ts index 818b72e97ad..78a78f3ac7d 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-transaction-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/get-transaction-endpoint.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorBesu } from "../plugin-ledger-connector-besu"; @@ -92,7 +95,7 @@ export class GetTransactionEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/invoke-contract-endpoint.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/invoke-contract-endpoint.ts index 7c3749408ae..656f915e31b 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/invoke-contract-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/invoke-contract-endpoint.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorBesu } from "../plugin-ledger-connector-besu"; @@ -92,7 +95,7 @@ export class InvokeContractEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/run-transaction-endpoint.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/run-transaction-endpoint.ts index 400002148c6..c90eee32be5 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/run-transaction-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/run-transaction-endpoint.ts @@ -12,7 +12,10 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorBesu } from "../plugin-ledger-connector-besu"; @@ -93,7 +96,7 @@ export class RunTransactionEndpoint implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/sign-transaction-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/sign-transaction-endpoint-v1.ts index 3cdef13a337..3c7c7c8867a 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/sign-transaction-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/main/typescript/web-services/sign-transaction-endpoint-v1.ts @@ -1,6 +1,9 @@ import { Express, Request, Response } from "express"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { IWebServiceEndpoint, @@ -101,16 +104,28 @@ export class BesuSignTransactionEndpointV1 implements IWebServiceEndpoint { } } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && typeof ex.message === 'string') { - const errorMsg = ex.message - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - } - } - else { + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + typeof ex.message === "string" + ) { + const errorMsg = ex.message; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); + } else { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `Internal server Error`; - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/invoke-contract.test.ts b/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/invoke-contract.test.ts index 45873edac3d..771a58283c7 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/invoke-contract.test.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/invoke-contract.test.ts @@ -200,8 +200,10 @@ describe(testCase, () => { }); expect(setNameOutInvalid.transactionReceipt).toBeFalsy(); } catch (error) { - if (typeof error === 'object' && error !== null) { - if ('message' in error && typeof error.message === 'string') { expect(error.message).toMatch("Nonce too low"); } + if (typeof error === "object" && error !== null) { + if ("message" in error && typeof error.message === "string") { + expect(error.message).toMatch("Nonce too low"); + } } } @@ -301,8 +303,10 @@ describe(testCase, () => { }); expect(setNameOutInvalid.transactionReceipt).toBeFalsy(); } catch (error) { - if (typeof error === 'object' && error !== null) { - if ('message' in error && typeof error.message === 'string') { expect(error.message).toMatch("Nonce too low"); } + if (typeof error === "object" && error !== null) { + if ("message" in error && typeof error.message === "string") { + expect(error.message).toMatch("Nonce too low"); + } } } diff --git a/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/openapi/openapi-validation.test.ts b/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/openapi/openapi-validation.test.ts index e96f2689aab..9e08a582c43 100644 --- a/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/openapi/openapi-validation.test.ts +++ b/packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/openapi/openapi-validation.test.ts @@ -214,7 +214,7 @@ describe("PluginLedgerConnectorBesu", () => { parameters as unknown as DeployContractSolidityBytecodeV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: { readonly path: string }) => param.path.replace("/body/", ""), @@ -246,7 +246,7 @@ describe("PluginLedgerConnectorBesu", () => { parameters as DeployContractSolidityBytecodeV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: { readonly path: string }) => param.path.replace("/body/", ""), @@ -293,7 +293,7 @@ describe("PluginLedgerConnectorBesu", () => { parameters as any as InvokeContractV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: { readonly path: string }) => param.path.replace("/body/", ""), @@ -320,7 +320,7 @@ describe("PluginLedgerConnectorBesu", () => { }; await apiClient.invokeContractV1(parameters as InvokeContractV1Request); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: { readonly path: string }) => param.path.replace("/body/", ""), @@ -374,7 +374,7 @@ describe("PluginLedgerConnectorBesu", () => { }; await apiClient.runTransactionV1(parameters as RunTransactionRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: { readonly path: string }) => param.path.replace("/body/", ""), @@ -406,7 +406,7 @@ describe("PluginLedgerConnectorBesu", () => { }; await apiClient.runTransactionV1(parameters as RunTransactionRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: { readonly path: string }) => param.path.replace("/body/", ""), @@ -498,7 +498,7 @@ describe("PluginLedgerConnectorBesu", () => { await apiClient.signTransactionV1(parameters as SignTransactionRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: any) => param.path.replace("/body/", ""), @@ -542,7 +542,7 @@ describe("PluginLedgerConnectorBesu", () => { await apiClient.signTransactionV1(parameters as SignTransactionRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: { readonly path: string }) => param.path.replace("/body/", ""), @@ -563,7 +563,7 @@ describe("PluginLedgerConnectorBesu", () => { const parameters = {}; await apiClient.getBalanceV1(parameters as GetBalanceV1Request); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: { readonly path: string }) => param.path.replace("/body/", ""), @@ -580,7 +580,7 @@ describe("PluginLedgerConnectorBesu", () => { }; await apiClient.getBalanceV1(parameters as GetBalanceV1Request); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: { readonly path: string }) => param.path.replace("/body/", ""), @@ -601,7 +601,7 @@ describe("PluginLedgerConnectorBesu", () => { const parameters = {}; await apiClient.getBlockV1(parameters as GetBlockV1Request); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: { readonly path: string }) => param.path.replace("/body/", ""), @@ -618,7 +618,7 @@ describe("PluginLedgerConnectorBesu", () => { }; await apiClient.getBlockV1(parameters as GetBlockV1Request); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: { readonly path: string }) => param.path.replace("/body/", ""), @@ -641,7 +641,7 @@ describe("PluginLedgerConnectorBesu", () => { const parameters = {}; await apiClient.getPastLogsV1(parameters as GetPastLogsV1Request); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: { readonly path: string }) => param.path.replace("/body/", ""), @@ -658,7 +658,7 @@ describe("PluginLedgerConnectorBesu", () => { }; await apiClient.getPastLogsV1(parameters as GetPastLogsV1Request); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: { readonly path: string }) => param.path.replace("/body/", ""), @@ -709,7 +709,7 @@ describe("PluginLedgerConnectorBesu", () => { const parameters = {}; await apiClient.getBesuRecordV1(parameters as GetBesuRecordV1Request); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: any) => param.path.replace("/body/", ""), @@ -726,7 +726,7 @@ describe("PluginLedgerConnectorBesu", () => { }; await apiClient.getBesuRecordV1(parameters as GetBesuRecordV1Request); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; expect(e?.response?.status).toEqual(400); const fields = e?.response?.data.map((param: { readonly path: string }) => param.path.replace("/body/", ""), diff --git a/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/get-lineage-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/get-lineage-v1-endpoint.ts index d511a572fba..2a4ee2a3921 100644 --- a/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/get-lineage-v1-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/get-lineage-v1-endpoint.ts @@ -12,10 +12,12 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorCDL } from "../plugin-ledger-connector-cdl"; import OAS from "../../json/openapi.json"; @@ -89,11 +91,8 @@ export class GetLineageDataEndpoint implements IWebServiceEndpoint { res.status(200).json(await this.options.connector.getLineage(req.body)); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/register-history-data-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/register-history-data-v1-endpoint.ts index 81155dc4e29..0dc88a3b9ca 100644 --- a/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/register-history-data-v1-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/register-history-data-v1-endpoint.ts @@ -12,10 +12,12 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorCDL } from "../plugin-ledger-connector-cdl"; import OAS from "../../json/openapi.json"; @@ -92,10 +94,8 @@ export class RegisterHistoryDataEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/search-lineage-by-globaldata-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/search-lineage-by-globaldata-v1-endpoint.ts index 1e6d7e7e8c9..f360b3cce0b 100644 --- a/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/search-lineage-by-globaldata-v1-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/search-lineage-by-globaldata-v1-endpoint.ts @@ -12,10 +12,12 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorCDL } from "../plugin-ledger-connector-cdl"; import OAS from "../../json/openapi.json"; @@ -92,10 +94,8 @@ export class SearchLineageByGlobalDataEndpoint implements IWebServiceEndpoint { } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/search-lineage-by-header-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/search-lineage-by-header-v1-endpoint.ts index 31f8de69485..13c7667c4a0 100644 --- a/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/search-lineage-by-header-v1-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-cdl/src/main/typescript/web-services/search-lineage-by-header-v1-endpoint.ts @@ -12,10 +12,12 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorCDL } from "../plugin-ledger-connector-cdl"; import OAS from "../../json/openapi.json"; @@ -91,11 +93,8 @@ export class SearchLineageByHeaderEndpoint implements IWebServiceEndpoint { .json(await this.options.connector.searchLineageByHeader(req.body)); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/deploy-contract-jars-endpoint.ts b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/deploy-contract-jars-endpoint.ts index 090e53497ef..a90f8164bc9 100644 --- a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/deploy-contract-jars-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/deploy-contract-jars-endpoint.ts @@ -134,12 +134,19 @@ export class DeployContractJarsEndpoint implements IWebServiceEndpoint { res.json(body); } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && typeof ex.message === 'string') { - const errorMsg = ex.message - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - - } + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + typeof ex.message === "string" + ) { + const errorMsg = ex.message; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } } } diff --git a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/diagnose-node-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/diagnose-node-endpoint-v1.ts index 1440c133ef8..f467e211881 100644 --- a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/diagnose-node-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/diagnose-node-endpoint-v1.ts @@ -17,7 +17,10 @@ import { import OAS from "../../json/openapi.json"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { DefaultApi, DiagnoseNodeV1Request, @@ -97,12 +100,19 @@ export class DiagnoseNodeEndpointV1 implements IWebServiceEndpoint { res.send(resBody); } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && typeof ex.message === 'string') { - const errorMsg = ex.message - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - - } + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + typeof ex.message === "string" + ) { + const errorMsg = ex.message; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } } } diff --git a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts index bc20608d17b..842de9c1cea 100644 --- a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -16,7 +16,10 @@ import { import OAS from "../../json/openapi.json"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorCorda } from "../plugin-ledger-connector-corda"; @@ -26,7 +29,8 @@ export interface IGetPrometheusExporterMetricsEndpointV1Options { } export class GetPrometheusExporterMetricsEndpointV1 - implements IWebServiceEndpoint { + implements IWebServiceEndpoint +{ private readonly log: Logger; constructor( @@ -93,12 +97,19 @@ export class GetPrometheusExporterMetricsEndpointV1 res.send(resBody); } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && typeof ex.message === 'string') { - const errorMsg = ex.message - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - - } + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + typeof ex.message === "string" + ) { + const errorMsg = ex.message; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } } } diff --git a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/invoke-contract-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/invoke-contract-endpoint-v1.ts index ee5ec093e53..db0380b3668 100644 --- a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/invoke-contract-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/invoke-contract-endpoint-v1.ts @@ -17,7 +17,10 @@ import { import OAS from "../../json/openapi.json"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { DefaultApi, InvokeContractV1Request, @@ -97,12 +100,19 @@ export class InvokeContractEndpointV1 implements IWebServiceEndpoint { res.send(resBody); } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && typeof ex.message === 'string') { - const errorMsg = ex.message - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - - } + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + typeof ex.message === "string" + ) { + const errorMsg = ex.message; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } } } diff --git a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/list-flows-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/list-flows-endpoint-v1.ts index 6642fe92ebb..6141931cecb 100644 --- a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/list-flows-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/list-flows-endpoint-v1.ts @@ -17,7 +17,10 @@ import { import OAS from "../../json/openapi.json"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { DefaultApi, ListFlowsV1Request, @@ -102,12 +105,19 @@ export class ListFlowsEndpointV1 implements IWebServiceEndpoint { res.send(resBody); } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && typeof ex.message === 'string') { - const errorMsg = ex.message - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - - } + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + typeof ex.message === "string" + ) { + const errorMsg = ex.message; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } } } diff --git a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/network-map-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/network-map-endpoint-v1.ts index 5be67d2995d..6832141947c 100644 --- a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/network-map-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/web-services/network-map-endpoint-v1.ts @@ -17,7 +17,10 @@ import { import OAS from "../../json/openapi.json"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { DefaultApi, NodeInfo } from "../generated/openapi/typescript-axios"; export interface INetworkMapEndpointV1Options { @@ -93,12 +96,19 @@ export class NetworkMapEndpointV1 implements IWebServiceEndpoint { res.send(resBody); } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && typeof ex.message === 'string') { - const errorMsg = ex.message - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - - } + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + typeof ex.message === "string" + ) { + const errorMsg = ex.message; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } } } diff --git a/packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/openapi/openapi-validation.test.ts b/packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/openapi/openapi-validation.test.ts index 0d731bcf836..3649aa422b3 100644 --- a/packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/openapi/openapi-validation.test.ts +++ b/packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/openapi/openapi-validation.test.ts @@ -435,7 +435,7 @@ test(testCase, async (t: Test) => { await apiClient.deployContractJarsV1(depReq); t2.fail(`${fDeploy} - ${cWithoutParams}: should fail`); } catch (e) { - const err = e as AxiosError<{ status: number }> + const err = e as AxiosError<{ status: number }>; t2.equal( err.response?.data?.status, @@ -456,7 +456,7 @@ test(testCase, async (t: Test) => { await apiClient.invokeContractV1(req); t2.fail(`${fInvoke} - ${cWithoutParams}: should fail`); } catch (e) { - const err = e as AxiosError<{ status: number }> + const err = e as AxiosError<{ status: number }>; t2.equal( err.response?.data?.status, @@ -477,7 +477,7 @@ test(testCase, async (t: Test) => { await apiClient.deployContractJarsV1(depReq); t2.fail(`${fDeploy} - ${cInvalidParams}: should fail`); } catch (e) { - const err = e as AxiosError<{ status: number }> + const err = e as AxiosError<{ status: number }>; t2.equal( err.response?.data?.status, @@ -494,7 +494,7 @@ test(testCase, async (t: Test) => { await apiClient.listFlowsV1(req); t2.fail(`${fFlows} - ${cInvalidParams}: should fail`); } catch (e) { - const err = e as AxiosError<{ status: number }> + const err = e as AxiosError<{ status: number }>; t2.equal( err.response?.data?.status, @@ -511,7 +511,7 @@ test(testCase, async (t: Test) => { await apiClient.diagnoseNodeV1(req); t2.fail(`${fDiagnose} - ${cInvalidParams}: should fail`); } catch (e) { - const err = e as AxiosError<{ status: number }> + const err = e as AxiosError<{ status: number }>; t2.equal( err.response?.data?.status, @@ -767,7 +767,7 @@ test(testCase, async (t: Test) => { await apiClient.invokeContractV1(req); t2.fail(`${fInvoke} - ${cInvalidParams}: should fail`); } catch (e) { - const err = e as AxiosError<{ status: number }> + const err = e as AxiosError<{ status: number }>; t2.equal( err.response?.data?.status, @@ -780,6 +780,3 @@ test(testCase, async (t: Test) => { t.end(); }); - - - diff --git a/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/plugin-ledger-connector-ethereum.ts b/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/plugin-ledger-connector-ethereum.ts index 62163b72a9d..1e434bf8ede 100644 --- a/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/plugin-ledger-connector-ethereum.ts +++ b/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/plugin-ledger-connector-ethereum.ts @@ -94,9 +94,9 @@ const waitForWsProviderRequestsTimeout = 5 * 1000; // 5s const waitForWsProviderRequestsStep = 500; // 500ms type RunContractDeploymentInput = { web3SigningCredential: - | Web3SigningCredentialCactiKeychainRef - | Web3SigningCredentialGethKeychainPassword - | Web3SigningCredentialPrivateKeyHex; + | Web3SigningCredentialCactiKeychainRef + | Web3SigningCredentialGethKeychainPassword + | Web3SigningCredentialPrivateKeyHex; contractJSON: ContractJSON; gasConfig?: GasTransactionConfig; constructorArgs?: unknown[]; @@ -131,14 +131,15 @@ export interface IPluginLedgerConnectorEthereumOptions export class PluginLedgerConnectorEthereum implements - IPluginLedgerConnector< - DeployContractV1Request, - RunTransactionResponse, - RunTransactionRequest, - RunTransactionResponse - >, - ICactusPlugin, - IPluginWebService { + IPluginLedgerConnector< + DeployContractV1Request, + RunTransactionResponse, + RunTransactionRequest, + RunTransactionResponse + >, + ICactusPlugin, + IPluginWebService +{ private readonly pluginRegistry: PluginRegistry; public prometheusExporter: PrometheusExporter; private readonly instanceId: string; @@ -695,16 +696,16 @@ export class PluginLedgerConnectorEthereum } else { throw new Error( `${fnTag} Expected pre-signed raw transaction ` + - ` since signing credential is specified as` + - `Web3SigningCredentialType.NONE`, + ` since signing credential is specified as` + + `Web3SigningCredentialType.NONE`, ); } } default: { throw new Error( `${fnTag} Unrecognized Web3SigningCredentialType: ` + - `${req.web3SigningCredential.type} Supported ones are: ` + - `${Object.values(Web3SigningCredentialType).join(";")}`, + `${req.web3SigningCredential.type} Supported ones are: ` + + `${Object.values(Web3SigningCredentialType).join(";")}`, ); } } @@ -801,15 +802,14 @@ export class PluginLedgerConnectorEthereum if (ex instanceof Error) { throw new Error( `${fnTag} Failed to invoke web3.eth.personal.sendTransaction(). ` + - `InnerException: ${ex.stack}`, + `InnerException: ${ex.stack}`, ); } else { throw new Error( `${fnTag} Failed to invoke web3.eth.personal.sendTransaction(). ` + - `Error: ${ex}`, + `Error: ${ex}`, ); } - } } @@ -837,7 +837,7 @@ export class PluginLedgerConnectorEthereum } else { throw new Error( `${fnTag} Failed to sign eth transaction. ` + - `signedTransaction.rawTransaction is blank after .signTransaction().`, + `signedTransaction.rawTransaction is blank after .signTransaction().`, ); } } diff --git a/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/web-services/get-prometheus-exporter-metrics-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/web-services/get-prometheus-exporter-metrics-v1-endpoint.ts index 792e2b25bd1..bad03c05d67 100644 --- a/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/web-services/get-prometheus-exporter-metrics-v1-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-ethereum/src/main/typescript/web-services/get-prometheus-exporter-metrics-v1-endpoint.ts @@ -1,6 +1,9 @@ import { Express, Request, Response } from "express"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; @@ -16,7 +19,6 @@ import { LoggerProvider, Checks, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; import { PluginLedgerConnectorEthereum } from "../plugin-ledger-connector-ethereum"; @@ -27,7 +29,8 @@ export interface IGetPrometheusExporterMetricsEndpointV1Options { } export class GetPrometheusExporterMetricsEndpointV1 - implements IWebServiceEndpoint { + implements IWebServiceEndpoint +{ private readonly log: Logger; constructor( @@ -84,6 +87,7 @@ export class GetPrometheusExporterMetricsEndpointV1 async handleRequest(req: Request, res: Response): Promise { const fnTag = "GetPrometheusExporterMetrics#handleRequest()"; + const reqTag = `${this.getVerbLowerCase()} - ${this.getPath()}`; const verbUpper = this.getVerbLowerCase().toUpperCase(); this.log.debug(`${verbUpper} ${this.getPath()}`); @@ -92,16 +96,21 @@ export class GetPrometheusExporterMetricsEndpointV1 .status(200) .send(await this.options.connector.getPrometheusExporterMetrics()); } catch (ex) { - if (typeof ex === 'object' && ex !== null) { - - if ('message' in ex && typeof ex.message === 'string') { - - const errorMsg = ex.message - - handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) - - } - + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + typeof ex.message === "string" + ) { + this.log.error(`Crash while serving ${reqTag} in ${fnTag}`, ex); + const errorMsg = ex.message; + + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, + }); } } } diff --git a/packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-using-json-object-v1.test.ts b/packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-using-json-object-v1.test.ts index 134eb63cd56..8c6815ad9aa 100644 --- a/packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-using-json-object-v1.test.ts +++ b/packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-using-json-object-v1.test.ts @@ -52,9 +52,9 @@ const containerImageVersion = "2023-07-27-2a8c48ed6"; describe("Ethereum contract deploy and invoke using keychain tests", () => { const keychainEntryKey = uuidV4(); let testEthAccount: { - address: HexString; - privateKey: HexString; - }, + address: HexString; + privateKey: HexString; + }, web3: InstanceType, addressInfo, address: string, diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/deploy-contract/deploy-contract-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/deploy-contract/deploy-contract-endpoint-v1.ts index ed262694d7c..4a0fc3869e3 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/deploy-contract/deploy-contract-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/deploy-contract/deploy-contract-endpoint-v1.ts @@ -7,7 +7,6 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; import { @@ -16,7 +15,10 @@ import { IEndpointAuthzOptions, } from "@hyperledger/cactus-core-api"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorFabric } from "../plugin-ledger-connector-fabric"; import { DeployContractV1Request } from "../generated/openapi/typescript-axios/index"; @@ -98,21 +100,13 @@ export class DeployContractEndpointV1 implements IWebServiceEndpoint { res.json(resBody); } catch (ex) { this.log.error(`${fnTag} failed to serve contract deploy request`, ex); - res.status(HttpStatus.INTERNAL_SERVER_ERROR).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), + const errorMsg = `Internal server Error`; + handleRestEndpointException({ + errorMsg, + log: this.log, + error: ex, + res, }); } } } - - -// { -// this.log.error(`${fnTag} failed to serve contract deploy request`, ex); -// if (typeof ex === 'object' && ex !== null) { -// if ('message' in ex && typeof ex.message === 'string') {= -// const errorMsg = ex.message -// handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }) -// } -// } -// } \ No newline at end of file diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-block/get-block-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-block/get-block-endpoint-v1.ts index 763ed05573b..de9a9cdb4e9 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-block/get-block-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-block/get-block-endpoint-v1.ts @@ -6,7 +6,6 @@ import { LogLevelDesc, Checks, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; import { @@ -15,7 +14,10 @@ import { IEndpointAuthzOptions, } from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorFabric } from "../plugin-ledger-connector-fabric"; import OAS from "../../json/openapi.json"; @@ -87,12 +89,10 @@ export class GetBlockEndpointV1 implements IWebServiceEndpoint { try { res.status(200).send(await this.opts.connector.getBlock(req.body)); - } catch (error) { - this.log.error(`Crash while serving ${fnTag}`, error); - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(error), - }); + } catch (ex) { + this.log.error(`Crash while serving ${fnTag}`, ex); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts index b5b6794407d..2fd6b45bd09 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-prometheus-exporter-metrics/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -6,7 +6,6 @@ import { LogLevelDesc, Checks, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; import { @@ -17,7 +16,10 @@ import { import OAS from "../../json/openapi.json"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorFabric } from "../plugin-ledger-connector-fabric"; @@ -27,7 +29,8 @@ export interface IGetPrometheusExporterMetricsEndpointV1Options { } export class GetPrometheusExporterMetricsEndpointV1 - implements IWebServiceEndpoint { + implements IWebServiceEndpoint +{ private readonly log: Logger; constructor( @@ -93,10 +96,8 @@ export class GetPrometheusExporterMetricsEndpointV1 res.send(resBody); } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-transaction-receipt/get-transaction-receipt-by-txid-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-transaction-receipt/get-transaction-receipt-by-txid-endpoint-v1.ts index 943188d0ac6..57d002121b3 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-transaction-receipt/get-transaction-receipt-by-txid-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/get-transaction-receipt/get-transaction-receipt-by-txid-endpoint-v1.ts @@ -6,7 +6,6 @@ import { LogLevelDesc, Checks, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; import { @@ -15,7 +14,10 @@ import { IEndpointAuthzOptions, } from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorFabric } from "../plugin-ledger-connector-fabric"; import { RunTransactionRequest } from "../generated/openapi/typescript-axios"; @@ -27,7 +29,8 @@ export interface IRunTransactionEndpointV1Options { } export class GetTransactionReceiptByTxIDEndpointV1 - implements IWebServiceEndpoint { + implements IWebServiceEndpoint +{ private readonly log: Logger; constructor(public readonly opts: IRunTransactionEndpointV1Options) { @@ -95,10 +98,8 @@ export class GetTransactionReceiptByTxIDEndpointV1 res.json(resBody); } catch (ex) { this.log.error(`${fnTag} failed to serve request`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/plugin-ledger-connector-fabric.ts b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/plugin-ledger-connector-fabric.ts index c345bff3569..1bb403ab0f5 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/plugin-ledger-connector-fabric.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/plugin-ledger-connector-fabric.ts @@ -188,14 +188,15 @@ export interface IPluginLedgerConnectorFabricOptions export class PluginLedgerConnectorFabric implements - IPluginLedgerConnector< - DeployContractV1Request, - DeployContractV1Response, - RunTransactionRequest, - RunTransactionResponse - >, - ICactusPlugin, - IPluginWebService { + IPluginLedgerConnector< + DeployContractV1Request, + DeployContractV1Response, + RunTransactionRequest, + RunTransactionResponse + >, + ICactusPlugin, + IPluginWebService +{ public static readonly CLASS_NAME = "PluginLedgerConnectorFabric"; private readonly instanceId: string; private readonly log: Logger; @@ -1114,11 +1115,16 @@ export class PluginLedgerConnectorFabric } } catch (ex) { this.log.error(`Building transient map crashed: `, ex); - if (typeof ex === 'object' && ex !== null) { - if ('message' in ex && typeof ex.message === 'string') { - throw new Error(`Unable to build the transient map: ${ex.message}`); - } - } else { throw new Error(`Unable to build the transient map. Error: ${ex}`); } + if ( + typeof ex === "object" && + ex !== null && + "message" in ex && + typeof ex.message === "string" + ) { + throw new Error(`Unable to build the transient map: ${ex.message}`); + } else { + throw new Error(`Unable to build the transient map. Error: ${ex}`); + } } return transientMap; @@ -1223,9 +1229,10 @@ export class PluginLedgerConnectorFabric if (ex instanceof Error) { throw new Error(`${fnTag} Inner Exception: ${ex?.message}`); - } else { throw new Error(`${fnTag} Exception: ${ex}`) } + } else { + throw new Error(`${fnTag} Exception: ${ex}`); + } } - } public async getTransactionReceiptByTxID( @@ -1264,8 +1271,9 @@ export class PluginLedgerConnectorFabric if (ex instanceof Error) { throw new Error(`${fnTag} Inner Exception: ${ex?.message}`); - } else { throw new Error(`${fnTag} Exception: ${ex}`) } - + } else { + throw new Error(`${fnTag} Exception: ${ex}`); + } } } @@ -1303,7 +1311,9 @@ export class PluginLedgerConnectorFabric this.log.error(`enrollAdmin() Failure:`, ex); if (ex instanceof Error) { throw new Error(`${fnTag} Inner Exception: ${ex?.message}`); - } else { throw new Error(`${fnTag} Exception: ${ex}`) } + } else { + throw new Error(`${fnTag} Exception: ${ex}`); + } } } /** @@ -1647,8 +1657,10 @@ export class PluginLedgerConnectorFabric } this.log.info( - `Created channel for ${channelName} with ${channel.getMspids().length - } Mspids, ${channel.getCommitters().length} commiters, ${channel.getEndorsers().length + `Created channel for ${channelName} with ${ + channel.getMspids().length + } Mspids, ${channel.getCommitters().length} commiters, ${ + channel.getEndorsers().length } endorsers`, ); @@ -1777,10 +1789,11 @@ export class PluginLedgerConnectorFabric let endorsedMethodResponse: Buffer | undefined; for (const response of endorsementResponse.responses) { - const endorsementStatus = `${response.connection.name}: ${response.response.status - } message ${response.response.message}, endorsement: ${Boolean( - response.endorsement, - )}`; + const endorsementStatus = `${response.connection.name}: ${ + response.response.status + } message ${response.response.message}, endorsement: ${Boolean( + response.endorsement, + )}`; if (response.response.status !== 200 || !response.endorsement) { this.log.warn(`Endorsement from peer ERROR: ${endorsementStatus}`); diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/run-transaction/run-delegated-sign-transaction-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/run-transaction/run-delegated-sign-transaction-endpoint-v1.ts index 257150c2e39..5bedd0a4563 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/run-transaction/run-delegated-sign-transaction-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/run-transaction/run-delegated-sign-transaction-endpoint-v1.ts @@ -6,7 +6,6 @@ import { LogLevelDesc, Checks, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; import { @@ -15,7 +14,10 @@ import { IEndpointAuthzOptions, } from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorFabric } from "../plugin-ledger-connector-fabric"; import OAS from "../../json/openapi.json"; @@ -26,8 +28,7 @@ export interface IRunDelegatedSignTransactionEndpointV1Options { } export class RunDelegatedSignTransactionEndpointV1 - implements IWebServiceEndpoint -{ + implements IWebServiceEndpoint { private readonly log: Logger; constructor( @@ -91,12 +92,10 @@ export class RunDelegatedSignTransactionEndpointV1 res .status(200) .json(await this.opts.connector.transactDelegatedSign(req.body)); - } catch (error) { - this.log.error(`Crash while serving ${fnTag}`, error); - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(error), - }); + } catch (ex) { + this.log.error(`Crash while serving ${fnTag}`, ex); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/run-transaction/run-transaction-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/run-transaction/run-transaction-endpoint-v1.ts index 38173ef24db..0eacbf66f51 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/run-transaction/run-transaction-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/main/typescript/run-transaction/run-transaction-endpoint-v1.ts @@ -6,7 +6,6 @@ import { LogLevelDesc, Checks, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; import { @@ -15,7 +14,10 @@ import { IEndpointAuthzOptions, } from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorFabric } from "../plugin-ledger-connector-fabric"; import OAS from "../../json/openapi.json"; @@ -85,12 +87,10 @@ export class RunTransactionEndpointV1 implements IWebServiceEndpoint { try { res.status(200).json(await this.opts.connector.transact(req.body)); - } catch (error) { - this.log.error(`Crash while serving ${fnTag}`, error); - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(error), - }); + } catch (ex) { + this.log.error(`Crash while serving ${fnTag}`, ex); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/openapi/openapi-validation-go.test.ts b/packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/openapi/openapi-validation-go.test.ts index 7b21f4b2c25..db83092b402 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/openapi/openapi-validation-go.test.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/openapi/openapi-validation-go.test.ts @@ -172,7 +172,7 @@ test(testCase, async (t: Test) => { parameters as any as DeployContractGoSourceV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -235,7 +235,7 @@ test(testCase, async (t: Test) => { parameters as any as DeployContractGoSourceV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/openapi/openapi-validation.test.ts b/packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/openapi/openapi-validation.test.ts index e638c4fadd0..ec36ae24698 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/openapi/openapi-validation.test.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/openapi/openapi-validation.test.ts @@ -292,7 +292,7 @@ test(testCase, async (t: Test) => { parameters as unknown as DeployContractV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -334,7 +334,7 @@ test(testCase, async (t: Test) => { try { await apiClient.deployContractV1(parameters as DeployContractV1Request); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -395,7 +395,7 @@ test(testCase, async (t: Test) => { try { await apiClient.runTransactionV1(parameters as RunTransactionRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -433,7 +433,7 @@ test(testCase, async (t: Test) => { try { await apiClient.runTransactionV1(parameters as RunTransactionRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, diff --git a/packages/cactus-plugin-ledger-connector-iroha2/src/main/typescript/web-services/generate-transaction-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-iroha2/src/main/typescript/web-services/generate-transaction-v1-endpoint.ts index 0e374cdab06..fc08a12bb59 100644 --- a/packages/cactus-plugin-ledger-connector-iroha2/src/main/typescript/web-services/generate-transaction-v1-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-iroha2/src/main/typescript/web-services/generate-transaction-v1-endpoint.ts @@ -16,10 +16,12 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorIroha2 } from "../plugin-ledger-connector-iroha2"; -import { safeStringifyException } from "../utils"; import OAS from "../../json/openapi.json"; @@ -29,8 +31,7 @@ export interface IGenerateTransactionOptions { } export class Iroha2GenerateTransactionEndpointV1 - implements IWebServiceEndpoint -{ + implements IWebServiceEndpoint { public static readonly CLASS_NAME = "GenerateTransaction"; private readonly log: Logger; @@ -101,10 +102,8 @@ export class Iroha2GenerateTransactionEndpointV1 res.send(txPayload); } catch (ex) { this.log.warn(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-iroha2/src/main/typescript/web-services/transact-v1-endpoint.ts b/packages/cactus-plugin-ledger-connector-iroha2/src/main/typescript/web-services/transact-v1-endpoint.ts index 6066495d466..41f7f98680b 100644 --- a/packages/cactus-plugin-ledger-connector-iroha2/src/main/typescript/web-services/transact-v1-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-iroha2/src/main/typescript/web-services/transact-v1-endpoint.ts @@ -16,10 +16,12 @@ import { IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginLedgerConnectorIroha2 } from "../plugin-ledger-connector-iroha2"; -import { safeStringifyException } from "../utils"; import OAS from "../../json/openapi.json"; @@ -97,10 +99,8 @@ export class Iroha2TransactEndpointV1 implements IWebServiceEndpoint { res.json(resBody); } catch (ex) { this.log.warn(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-iroha2/src/test/typescript/integration/iroha2-generate-and-send-signed-transaction.test.ts b/packages/cactus-plugin-ledger-connector-iroha2/src/test/typescript/integration/iroha2-generate-and-send-signed-transaction.test.ts index 366c9c69b3f..9ac554727ba 100644 --- a/packages/cactus-plugin-ledger-connector-iroha2/src/test/typescript/integration/iroha2-generate-and-send-signed-transaction.test.ts +++ b/packages/cactus-plugin-ledger-connector-iroha2/src/test/typescript/integration/iroha2-generate-and-send-signed-transaction.test.ts @@ -31,16 +31,14 @@ import { addRandomSuffix } from "../test-helpers/utils"; import "jest-extended"; import { TransactionPayload } from "@iroha2/data-model"; import { signIrohaV2Query } from "../../../main/typescript/iroha-sign-utils"; -import { AxiosError } from "axios"; -import { ResponseError } from "@iroha2/client"; interface ErrorResponse extends Error { response?: { status?: number; data?: { message: string; - error: any - } + error: any; + }; }; } @@ -336,12 +334,10 @@ describe("Generate and send signed transaction tests", () => { } catch (err) { const errorResponse = err as ErrorResponse; expect(errorResponse?.response?.status).toBe(500); - expect(errorResponse?.response?.data?.message).toEqual("Internal Server Error"); + expect(errorResponse?.response?.data?.message).toEqual( + "Internal Server Error", + ); expect(errorResponse?.response?.data?.error).toBeTruthy(); - - - - } }); @@ -360,10 +356,11 @@ describe("Generate and send signed transaction tests", () => { }); expect(false).toBe(true); // should always throw by now } catch (err) { - const errorResponse = err as ErrorResponse; expect(errorResponse?.response?.status).toBe(500); - expect(errorResponse?.response?.data?.message).toEqual("Internal Server Error"); + expect(errorResponse?.response?.data?.message).toEqual( + "Internal Server Error", + ); expect(errorResponse?.response?.data?.error).toBeTruthy(); } }); diff --git a/packages/cactus-plugin-ledger-connector-polkadot/src/main/typescript/plugin-ledger-connector-polkadot.ts b/packages/cactus-plugin-ledger-connector-polkadot/src/main/typescript/plugin-ledger-connector-polkadot.ts index 9963005c8b0..cdab9b5236b 100644 --- a/packages/cactus-plugin-ledger-connector-polkadot/src/main/typescript/plugin-ledger-connector-polkadot.ts +++ b/packages/cactus-plugin-ledger-connector-polkadot/src/main/typescript/plugin-ledger-connector-polkadot.ts @@ -101,14 +101,15 @@ export interface IPluginLedgerConnectorPolkadotOptions export class PluginLedgerConnectorPolkadot implements - IPluginLedgerConnector< - DeployContractInkRequest, - DeployContractInkResponse, - RunTransactionRequest, - RunTransactionResponse - >, - ICactusPlugin, - IPluginWebService { + IPluginLedgerConnector< + DeployContractInkRequest, + DeployContractInkResponse, + RunTransactionRequest, + RunTransactionResponse + >, + ICactusPlugin, + IPluginWebService +{ public static readonly CLASS_NAME = "PluginLedgerConnectorPolkadot"; private readonly instanceId: string; private readonly log: Logger; @@ -849,7 +850,7 @@ export class PluginLedgerConnectorPolkadot } catch (err) { throw createHttpError[500]( `${fnTag} Obtaining Prometheus Exporter Metrics has failed. ` + - `InnerException: ${err}`, + `InnerException: ${err}`, ); } } @@ -899,7 +900,7 @@ export class PluginLedgerConnectorPolkadot } catch (err) { throw createHttpError[500]( `${fnTag} Obtaining info for this transaction has failed. ` + - `InnerException: ${err}`, + `InnerException: ${err}`, ); } } diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts index 14d506faf7b..0aee59d3100 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/plugin-ledger-connector-quorum.ts @@ -98,14 +98,15 @@ export interface IPluginLedgerConnectorQuorumOptions export class PluginLedgerConnectorQuorum implements - IPluginLedgerConnector< - DeployContractSolidityBytecodeV1Request, - DeployContractSolidityBytecodeV1Response, - RunTransactionRequest, - RunTransactionResponse - >, - ICactusPlugin, - IPluginWebService { + IPluginLedgerConnector< + DeployContractSolidityBytecodeV1Request, + DeployContractSolidityBytecodeV1Response, + RunTransactionRequest, + RunTransactionResponse + >, + ICactusPlugin, + IPluginWebService +{ private readonly pluginRegistry: PluginRegistry; public prometheusExporter: PrometheusExporter; private readonly instanceId: string; @@ -125,17 +126,17 @@ export class PluginLedgerConnectorQuorum if (!this.options.rpcApiWsHost) { return this.options.httpProviderOptions ? new Web3.providers.HttpProvider( - this.options.rpcApiHttpHost, - this.options.httpProviderOptions, - ) + this.options.rpcApiHttpHost, + this.options.httpProviderOptions, + ) : new Web3.providers.HttpProvider(this.options.rpcApiHttpHost); } return this.options.wsProviderOptions ? new Web3.providers.WebsocketProvider( - this.options.rpcApiWsHost, - this.options.wsProviderOptions, - ) + this.options.rpcApiWsHost, + this.options.wsProviderOptions, + ) : new Web3.providers.WebsocketProvider(this.options.rpcApiWsHost); } @@ -524,16 +525,16 @@ export class PluginLedgerConnectorQuorum } else { throw new Error( `${fnTag} Expected pre-signed raw transaction ` + - ` since signing credential is specified as` + - `Web3SigningCredentialType.NONE`, + ` since signing credential is specified as` + + `Web3SigningCredentialType.NONE`, ); } } default: { throw new Error( `${fnTag} Unrecognized Web3SigningCredentialType: ` + - `${req.web3SigningCredential.type} Supported ones are: ` + - `${Object.values(Web3SigningCredentialType).join(";")}`, + `${req.web3SigningCredential.type} Supported ones are: ` + + `${Object.values(Web3SigningCredentialType).join(";")}`, ); } } @@ -576,7 +577,7 @@ export class PluginLedgerConnectorQuorum } catch (ex) { throw new Error( `${fnTag} Failed to invoke web3.eth.personal.sendTransaction(). ` + - `InnerException: ${ex}`, + `InnerException: ${ex}`, ); } } @@ -603,7 +604,7 @@ export class PluginLedgerConnectorQuorum } else { throw new Error( `${fnTag} Failed to sign eth transaction. ` + - `signedTransaction.rawTransaction is blank after .signTransaction().`, + `signedTransaction.rawTransaction is blank after .signTransaction().`, ); } } @@ -923,8 +924,9 @@ export class PluginLedgerConnectorQuorum const isValidType = typeof argValue === input.type; if (!isValidType) { - const msg = `Invalid type for argument ${index + 1} in ${args.contractMethod - }`; + const msg = `Invalid type for argument ${index + 1} in ${ + args.contractMethod + }`; throw new BadRequestError(msg); } }); diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-json-object.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-json-object.ts index 4298d019a48..3ba0653b71f 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-json-object.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint-json-object.ts @@ -27,7 +27,8 @@ export interface IDeployContractSolidityBytecodeOptionsJsonObject { } export class DeployContractSolidityBytecodeJsonObjectEndpoint - implements IWebServiceEndpoint { + implements IWebServiceEndpoint +{ public static readonly CLASS_NAME = "DeployContractSolidityBytecodeEndpointJsonObject"; @@ -105,5 +106,3 @@ export class DeployContractSolidityBytecodeJsonObjectEndpoint } } } - - diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts index 20859b205f5..ea92ace2a40 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -27,7 +27,8 @@ export interface IGetPrometheusExporterMetricsEndpointV1Options { } export class GetPrometheusExporterMetricsEndpointV1 - implements IWebServiceEndpoint { + implements IWebServiceEndpoint +{ private readonly log: Logger; constructor( diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation-no-keychain.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation-no-keychain.test.ts index c3cabfec5b6..06dfb577449 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation-no-keychain.test.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation-no-keychain.test.ts @@ -192,7 +192,7 @@ test(testCase, async (t: Test) => { parameters as any as DeployContractSolidityBytecodeJsonObjectV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -229,7 +229,7 @@ test(testCase, async (t: Test) => { parameters as any as DeployContractSolidityBytecodeJsonObjectV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -266,7 +266,7 @@ test(testCase, async (t: Test) => { parameters as any as InvokeContractJsonObjectV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -306,7 +306,7 @@ test(testCase, async (t: Test) => { parameters as any as InvokeContractJsonObjectV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, diff --git a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation.test.ts b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation.test.ts index 5c3667a4bd3..52d74a20816 100644 --- a/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation.test.ts +++ b/packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/openapi/openapi-validation.test.ts @@ -181,7 +181,7 @@ test(testCase, async (t: Test) => { parameters as DeployContractSolidityBytecodeV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -217,7 +217,7 @@ test(testCase, async (t: Test) => { parameters as DeployContractSolidityBytecodeV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -279,7 +279,7 @@ test(testCase, async (t: Test) => { }; await apiClient.invokeContractV1(parameters as InvokeContractV1Request); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -318,7 +318,7 @@ test(testCase, async (t: Test) => { }; await apiClient.invokeContractV1(parameters as InvokeContractV1Request); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -370,7 +370,7 @@ test(testCase, async (t: Test) => { }; await apiClient.runTransactionV1(parameters as RunTransactionRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -406,7 +406,7 @@ test(testCase, async (t: Test) => { }; await apiClient.runTransactionV1(parameters as RunTransactionRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, diff --git a/packages/cactus-plugin-ledger-connector-sawtooth/src/main/typescript/web-services/status-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-sawtooth/src/main/typescript/web-services/status-endpoint-v1.ts index 392ad28ae34..90235d6c9e0 100644 --- a/packages/cactus-plugin-ledger-connector-sawtooth/src/main/typescript/web-services/status-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-sawtooth/src/main/typescript/web-services/status-endpoint-v1.ts @@ -8,14 +8,16 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; import type { IEndpointAuthzOptions, IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import OAS from "../../json/openapi.json"; import { PluginLedgerConnectorSawtooth } from "../plugin-ledger-connector-sawtooth"; @@ -95,10 +97,8 @@ export class StatusEndpointV1 implements IWebServiceEndpoint { res.status(200).json(await this.options.connector.getStatus()); } catch (ex) { this.log.error(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts index fd58762a5f7..34c176cfb9d 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-endpoint.ts @@ -27,7 +27,8 @@ export interface IDeployContractSolidityBytecodeOptions { } export class DeployContractSolidityBytecodeEndpoint - implements IWebServiceEndpoint { + implements IWebServiceEndpoint +{ public static readonly CLASS_NAME = "DeployContractSolidityBytecodeEndpoint"; private readonly log: Logger; diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-json-object-endpoint.ts b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-json-object-endpoint.ts index c34b60ebdc6..d7af23d4532 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-json-object-endpoint.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/deploy-contract-solidity-bytecode-json-object-endpoint.ts @@ -27,7 +27,8 @@ export interface IDeployContractSolidityBytecodeJsonObjectOptions { } export class DeployContractSolidityBytecodeJsonObjectEndpoint - implements IWebServiceEndpoint { + implements IWebServiceEndpoint +{ public static readonly CLASS_NAME = "DeployContractSolidityBytecodeJsonObjectEndpoint"; diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts index 2c2409f8c30..cac1673091d 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/main/typescript/web-services/get-prometheus-exporter-metrics-endpoint-v1.ts @@ -27,7 +27,8 @@ export interface IGetPrometheusExporterMetricsEndpointV1Options { } export class GetPrometheusExporterMetricsEndpointV1 - implements IWebServiceEndpoint { + implements IWebServiceEndpoint +{ private readonly log: Logger; constructor( diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/invoke-contract-xdai.test.ts b/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/invoke-contract-xdai.test.ts index a38f1dea2bb..bb5c3452644 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/invoke-contract-xdai.test.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/invoke-contract-xdai.test.ts @@ -311,7 +311,7 @@ describe(testCase, () => { if (error instanceof Error) { expect(error.message).toContain( "Transaction with the same hash was already imported", - ) + ); } else { console.error("Unexpected error type:", error); } diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation-no-keychain.test.ts b/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation-no-keychain.test.ts index 36a2da00cde..33fc6faed39 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation-no-keychain.test.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation-no-keychain.test.ts @@ -143,7 +143,7 @@ test(testCase, async (t: Test) => { parameters as any as DeployContractJsonObjectV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -178,14 +178,15 @@ test(testCase, async (t: Test) => { parameters as any as DeployContractJsonObjectV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, t2.equal( e?.response?.status, 400, `Endpoint ${fDeploy} with fake=4: response.status === 400 OK`, - )); + ), + ); const fields = e?.response?.data.map((param: any) => param.path.replace("/body/", ""), ); @@ -242,15 +243,15 @@ test(testCase, async (t: Test) => { parameters as any as InvokeContractJsonObjectV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, t2.equal( e?.response?.status, 400, `Endpoint ${fInvoke} without required contractJSON: response.status === 400 OK`, - ) - ) + ), + ); const fields = e?.response?.data.map((param: any) => param.path.replace("/body/", ""), ); @@ -283,14 +284,15 @@ test(testCase, async (t: Test) => { parameters as any as InvokeContractJsonObjectV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, t2.equal( e?.response?.status, 400, `Endpoint ${fInvoke} with fake=4: response.status === 400 OK`, - )) + ), + ); const fields = e?.response?.data.map((param: any) => param.path.replace("/body/", ""), ); diff --git a/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation.test.ts b/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation.test.ts index 0fef7d44f6f..e863af17abc 100644 --- a/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation.test.ts +++ b/packages/cactus-plugin-ledger-connector-xdai/src/test/typescript/integration/openapi/openapi-validation.test.ts @@ -167,7 +167,7 @@ test(testCase, async (t: Test) => { parameters as unknown as DeployContractV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -201,7 +201,7 @@ test(testCase, async (t: Test) => { }; await apiClient.deployContractV1(parameters); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -263,7 +263,7 @@ test(testCase, async (t: Test) => { parameters as unknown as InvokeContractV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -301,7 +301,7 @@ test(testCase, async (t: Test) => { parameters as any as InvokeContractV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -365,7 +365,7 @@ test(testCase, async (t: Test) => { parameters as any as RunTransactionV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -408,7 +408,7 @@ test(testCase, async (t: Test) => { parameters as any as RunTransactionV1Request, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, diff --git a/packages/cactus-plugin-persistence-ethereum/src/main/typescript/web-services/status-endpoint-v1.ts b/packages/cactus-plugin-persistence-ethereum/src/main/typescript/web-services/status-endpoint-v1.ts index 66a1d783584..7f1c43b0a9c 100644 --- a/packages/cactus-plugin-persistence-ethereum/src/main/typescript/web-services/status-endpoint-v1.ts +++ b/packages/cactus-plugin-persistence-ethereum/src/main/typescript/web-services/status-endpoint-v1.ts @@ -8,14 +8,16 @@ import { LogLevelDesc, LoggerProvider, IAsyncProvider, - safeStringifyException, } from "@hyperledger/cactus-common"; import type { IEndpointAuthzOptions, IExpressRequestHandler, IWebServiceEndpoint, } from "@hyperledger/cactus-core-api"; -import { registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginPersistenceEthereum } from "../plugin-persistence-ethereum"; import OAS from "../../json/openapi.json"; @@ -99,10 +101,8 @@ export class StatusEndpointV1 implements IWebServiceEndpoint { res.status(200).json(resBody); } catch (ex) { this.log.warn(`Crash while serving ${reqTag}`, ex); - res.status(500).json({ - message: "Internal Server Error", - error: safeStringifyException(ex), - }); + const errorMsg = "Internal Server Error"; + handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/client-request-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/client-request-endpoint.ts index 74606af0965..65217620e91 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/client-request-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/client-request-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; @@ -93,7 +96,6 @@ export class ClientRequestEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/commit-final-response-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/commit-final-response-endpoint.ts index 38f93a2f809..1fbccf94d8c 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/commit-final-response-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/commit-final-response-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; @@ -46,7 +49,7 @@ export class CommitFinalResponseEndpointV1 implements IWebServiceEndpoint { public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitfinalresponse" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitfinalresponse" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -54,7 +57,7 @@ export class CommitFinalResponseEndpointV1 implements IWebServiceEndpoint { public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitfinalresponse" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitfinalresponse" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -97,7 +100,6 @@ export class CommitFinalResponseEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/commit-prepare-response-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/commit-prepare-response-endpoint.ts index ecbf47dc845..0ff8fb58e55 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/commit-prepare-response-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/commit-prepare-response-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; @@ -25,7 +28,8 @@ export interface ICommitPreparationResponseEndpointOptions { } export class CommitPreparationResponseEndpointV1 - implements IWebServiceEndpoint { + implements IWebServiceEndpoint +{ public static readonly CLASS_NAME = "CommitPrepareResponseEndpointV1"; private readonly log: Logger; @@ -49,7 +53,7 @@ export class CommitPreparationResponseEndpointV1 public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitpreparationresponse" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitpreparationresponse" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -57,7 +61,7 @@ export class CommitPreparationResponseEndpointV1 public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitpreparationresponse" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitpreparationresponse" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -100,7 +104,6 @@ export class CommitPreparationResponseEndpointV1 this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/lock-evidence-response-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/lock-evidence-response-endpoint.ts index 02e99ca8139..4cd86ca9b4f 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/lock-evidence-response-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/lock-evidence-response-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; import OAS from "../../../json/openapi.json"; @@ -49,7 +52,7 @@ export class LockEvidenceResponseEndpointV1 implements IWebServiceEndpoint { public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/lockevidenceresponse" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/lockevidenceresponse" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -57,7 +60,7 @@ export class LockEvidenceResponseEndpointV1 implements IWebServiceEndpoint { public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/lockevidenceresponse" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/lockevidenceresponse" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -100,7 +103,6 @@ export class LockEvidenceResponseEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } -} \ No newline at end of file +} diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/transfer-commence-response-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/transfer-commence-response-endpoint.ts index a4dccec8908..998d397f30e 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/transfer-commence-response-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/transfer-commence-response-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; import OAS from "../../../json/openapi.json"; @@ -47,7 +50,7 @@ export class TransferCommenceResponseEndpointV1 implements IWebServiceEndpoint { public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/transfercommenceresponse" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/transfercommenceresponse" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -55,7 +58,7 @@ export class TransferCommenceResponseEndpointV1 implements IWebServiceEndpoint { public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/transfercommenceresponse" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/transfercommenceresponse" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -98,7 +101,6 @@ export class TransferCommenceResponseEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/transfer-initiation-response-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/transfer-initiation-response-endpoint.ts index 9ec15246f2d..4f48db4af13 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/transfer-initiation-response-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/client-side/transfer-initiation-response-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; import OAS from "../../../json/openapi.json"; @@ -24,7 +27,8 @@ export interface ITransferInitiationResponseEndpointOptions { } export class TransferInitiationResponseEndpointV1 - implements IWebServiceEndpoint { + implements IWebServiceEndpoint +{ public static readonly CLASS_NAME = "TransferInitiationResponseEndpointV1"; private readonly log: Logger; @@ -48,7 +52,7 @@ export class TransferInitiationResponseEndpointV1 public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase1/transferinitiationresponse" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase1/transferinitiationresponse" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -56,7 +60,7 @@ export class TransferInitiationResponseEndpointV1 public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase1/transferinitiationresponse" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase1/transferinitiationresponse" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -100,7 +104,6 @@ export class TransferInitiationResponseEndpointV1 this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-message-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-message-endpoint.ts index c187d865454..6c9d62f773d 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-message-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-message-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; @@ -46,7 +49,7 @@ export class RecoverMessageEndpointV1 implements IWebServiceEndpoint { public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recovermessage" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recovermessage" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -54,7 +57,7 @@ export class RecoverMessageEndpointV1 implements IWebServiceEndpoint { public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recovermessage" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recovermessage" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -97,7 +100,6 @@ export class RecoverMessageEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-success-message-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-success-message-endpoint.ts index 0ffcb2376e7..5a61fc0e375 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-success-message-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-success-message-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; @@ -46,7 +49,7 @@ export class RecoverSuccessMessageEndpointV1 implements IWebServiceEndpoint { public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recoversuccessmessage" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recoversuccessmessage" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -54,7 +57,7 @@ export class RecoverSuccessMessageEndpointV1 implements IWebServiceEndpoint { public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recoversuccessmessage" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recoversuccessmessage" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -98,7 +101,6 @@ export class RecoverSuccessMessageEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-update-ack-message-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-update-ack-message-endpoint.ts index 1c3e4d7840d..cd2b346aca5 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-update-ack-message-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-update-ack-message-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; @@ -48,7 +51,7 @@ export class RecoverUpdateAckMessageEndpointV1 implements IWebServiceEndpoint { public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recoverupdateackmessage" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recoverupdateackmessage" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -56,7 +59,7 @@ export class RecoverUpdateAckMessageEndpointV1 implements IWebServiceEndpoint { public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recoverupdateackmessage" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recoverupdateackmessage" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -99,7 +102,6 @@ export class RecoverUpdateAckMessageEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-update-message-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-update-message-endpoint.ts index 6860fcd0587..a8111b9aa88 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-update-message-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/recover-update-message-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; @@ -46,7 +49,7 @@ export class RecoverUpdateMessageEndpointV1 implements IWebServiceEndpoint { public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recoverupdatemessage" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recoverupdatemessage" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -54,7 +57,7 @@ export class RecoverUpdateMessageEndpointV1 implements IWebServiceEndpoint { public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recoverupdatemessage" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/recoverupdatemessage" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -97,7 +100,6 @@ export class RecoverUpdateMessageEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/rollback-ack-message-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/rollback-ack-message-endpoint.ts index fa865fb16a5..703424caf77 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/rollback-ack-message-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/rollback-ack-message-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; @@ -46,7 +49,7 @@ export class RollbackAckMessageEndpointV1 implements IWebServiceEndpoint { public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/rollbackackmessage" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/rollbackackmessage" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -54,7 +57,7 @@ export class RollbackAckMessageEndpointV1 implements IWebServiceEndpoint { public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/rollbackackmessage" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/rollbackackmessage" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -98,7 +101,6 @@ export class RollbackAckMessageEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/rollback-message-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/rollback-message-endpoint.ts index 07b644b0881..5fb33612e74 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/rollback-message-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/recovery/rollback-message-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; @@ -46,7 +49,7 @@ export class RollbackMessageEndpointV1 implements IWebServiceEndpoint { public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/rollbackmessage" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/rollbackmessage" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -54,7 +57,7 @@ export class RollbackMessageEndpointV1 implements IWebServiceEndpoint { public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/rollbackmessage" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/rollbackmessage" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -98,7 +101,6 @@ export class RollbackMessageEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/commit-final-request-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/commit-final-request-endpoint.ts index dcaa0dfe0ea..7fd7b4974b5 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/commit-final-request-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/commit-final-request-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; import OAS from "../../../json/openapi.json"; @@ -45,7 +48,7 @@ export class CommitFinalRequestEndpointV1 implements IWebServiceEndpoint { public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitfinalrequest" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitfinalrequest" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -53,7 +56,7 @@ export class CommitFinalRequestEndpointV1 implements IWebServiceEndpoint { public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitfinalrequest" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitfinalrequest" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -96,7 +99,6 @@ export class CommitFinalRequestEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/commite-prepare-request-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/commite-prepare-request-endpoint.ts index 70719a283bd..764594fc53c 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/commite-prepare-request-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/commite-prepare-request-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; import OAS from "../../../json/openapi.json"; @@ -47,7 +50,7 @@ export class CommitPreparationRequestEndpointV1 implements IWebServiceEndpoint { public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitpreparationrequest" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitpreparationrequest" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -55,7 +58,7 @@ export class CommitPreparationRequestEndpointV1 implements IWebServiceEndpoint { public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitpreparationrequest" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/commitpreparationrequest" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -98,7 +101,6 @@ export class CommitPreparationRequestEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/lock-evidence-request-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/lock-evidence-request-endpoint.ts index 0712daf7902..85859e74b00 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/lock-evidence-request-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/lock-evidence-request-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; import OAS from "../../../json/openapi.json"; @@ -49,7 +52,7 @@ export class LockEvidenceRequestEndpointV1 implements IWebServiceEndpoint { public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/lockevidencerequest" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/lockevidencerequest" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -57,7 +60,7 @@ export class LockEvidenceRequestEndpointV1 implements IWebServiceEndpoint { public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/lockevidencerequest" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/lockevidencerequest" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -100,7 +103,6 @@ export class LockEvidenceRequestEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/transfer-commence-request-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/transfer-commence-request-endpoint.ts index cba3d9a490f..f1d48f97996 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/transfer-commence-request-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/transfer-commence-request-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; import OAS from "../../../json/openapi.json"; @@ -47,7 +50,7 @@ export class TransferCommenceRequestEndpointV1 implements IWebServiceEndpoint { public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/transfercommencerequest" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/transfercommencerequest" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -55,7 +58,7 @@ export class TransferCommenceRequestEndpointV1 implements IWebServiceEndpoint { public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/transfercommencerequest" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase2/transfercommencerequest" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -98,7 +101,6 @@ export class TransferCommenceRequestEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/transfer-complete-request-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/transfer-complete-request-endpoint.ts index 2a160ec8ba0..42922af1ffe 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/transfer-complete-request-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/transfer-complete-request-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; import OAS from "../../../json/openapi.json"; @@ -47,7 +50,7 @@ export class TransferCompleteRequestEndpointV1 implements IWebServiceEndpoint { public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/transfercompleterequest" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/transfercompleterequest" ]; return apiPath.get["x-hyperledger-cacti"].http.path; } @@ -55,7 +58,7 @@ export class TransferCompleteRequestEndpointV1 implements IWebServiceEndpoint { public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/transfercompleterequest" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase3/transfercompleterequest" ]; return apiPath.get["x-hyperledger-cacti"].http.verbLowerCase; } @@ -98,7 +101,6 @@ export class TransferCompleteRequestEndpointV1 implements IWebServiceEndpoint { this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/transfer-initiation-request-endpoint.ts b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/transfer-initiation-request-endpoint.ts index 4b59a5d6b0c..deedd3d8aa5 100644 --- a/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/transfer-initiation-request-endpoint.ts +++ b/packages/cactus-plugin-satp-hermes/src/main/typescript/web-services/server-side/transfer-initiation-request-endpoint.ts @@ -13,7 +13,10 @@ import { IAsyncProvider, } from "@hyperledger/cactus-common"; -import { handleRestEndpointException, registerWebServiceEndpoint } from "@hyperledger/cactus-core"; +import { + handleRestEndpointException, + registerWebServiceEndpoint, +} from "@hyperledger/cactus-core"; import { PluginSatpGateway } from "../../gateway/plugin-satp-gateway"; import OAS from "../../../json/openapi.json"; @@ -24,7 +27,8 @@ export interface ITransferInitiationRequestEndpointOptions { } export class TransferInitiationRequestEndpointV1 - implements IWebServiceEndpoint { + implements IWebServiceEndpoint +{ public static readonly CLASS_NAME = "TransferInitiationRequestEndpointV1"; private readonly log: Logger; @@ -48,7 +52,7 @@ export class TransferInitiationRequestEndpointV1 public getPath(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase1/transferinitiationrequest" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase1/transferinitiationrequest" ]; return apiPath.post["x-hyperledger-cacti"].http.path; } @@ -56,7 +60,7 @@ export class TransferInitiationRequestEndpointV1 public getVerbLowerCase(): string { const apiPath = OAS.paths[ - "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase1/transferinitiationrequest" + "/api/v1/@hyperledger/cactus-plugin-satp-hermes/phase1/transferinitiationrequest" ]; return apiPath.post["x-hyperledger-cacti"].http.verbLowerCase; } @@ -100,7 +104,6 @@ export class TransferInitiationRequestEndpointV1 this.log.error(`Crash while serving ${reqTag}`, ex); const errorMsg = `${fnTag} request handler fn crashed for: ${reqTag}`; handleRestEndpointException({ errorMsg, log: this.log, error: ex, res }); - } } } diff --git a/packages/cactus-test-plugin-consortium-manual/src/test/typescript/integration/plugin-consortium-manual/openapi/openapi-validation.test.ts b/packages/cactus-test-plugin-consortium-manual/src/test/typescript/integration/plugin-consortium-manual/openapi/openapi-validation.test.ts index f712956ceb9..5bc4e3aa8cb 100644 --- a/packages/cactus-test-plugin-consortium-manual/src/test/typescript/integration/plugin-consortium-manual/openapi/openapi-validation.test.ts +++ b/packages/cactus-test-plugin-consortium-manual/src/test/typescript/integration/plugin-consortium-manual/openapi/openapi-validation.test.ts @@ -295,7 +295,7 @@ test(testCase, async (t: Test) => { try { await api.getNodeJwsV1({ fake: 4 }); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -319,7 +319,7 @@ test(testCase, async (t: Test) => { try { await api.getConsortiumJwsV1({ fake: 4 }); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, diff --git a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/initialize-endpoint.test.ts b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/initialize-endpoint.test.ts index 18dfd665302..927265faefa 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/initialize-endpoint.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/initialize-endpoint.test.ts @@ -205,7 +205,7 @@ describe(testCase, () => { const res = await api.initializeV1(request); expect(res.status).toEqual(400); } catch (err) { - const e = err as AxiosError + const e = err as AxiosError; expect(e?.response?.status).toEqual(400); } }); diff --git a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/new-contract-endpoint.test.ts b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/new-contract-endpoint.test.ts index c5dafa78a56..8e2c80b39f4 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/new-contract-endpoint.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/new-contract-endpoint.test.ts @@ -332,7 +332,7 @@ describe(testCase, () => { const res = await api.newContractV1(request); expect(res.status).toEqual(400); } catch (err) { - const e = err as AxiosError + const e = err as AxiosError; expect(e?.response?.status).toEqual(400); } }); diff --git a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/openapi/openapi-validation.test.ts b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/openapi/openapi-validation.test.ts index b18e282128c..2392b4aca32 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/openapi/openapi-validation.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/openapi/openapi-validation.test.ts @@ -219,11 +219,11 @@ test(testCase, async (t: Test) => { try { await api.initializeV1(parameters as any as InitializeRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, - `Endpoint ${fInitialize} waithout required connectorId: response.status === 400 OK`, + `Endpoint ${fInitialize} without required connectorId: response.status === 400 OK`, ); const fields = e?.response?.data.map((param: any) => param.path.replace("/body/", ""), @@ -249,7 +249,7 @@ test(testCase, async (t: Test) => { try { await api.initializeV1(parameters as any as InitializeRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -364,7 +364,7 @@ test(testCase, async (t: Test) => { try { await api.newContractV1(parameters as any as NewContractRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -402,7 +402,7 @@ test(testCase, async (t: Test) => { try { await api.newContractV1(parameters as any as NewContractRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -467,7 +467,7 @@ test(testCase, async (t: Test) => { try { await api.refundV1(parameters as any as RefundRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -493,7 +493,7 @@ test(testCase, async (t: Test) => { try { await api.refundV1(parameters as any as RefundRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -611,7 +611,7 @@ test(testCase, async (t: Test) => { try { await api.withdrawV1(parameters as any as WithdrawRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -639,7 +639,7 @@ test(testCase, async (t: Test) => { try { await api.withdrawV1(parameters as any as WithdrawRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -687,7 +687,7 @@ test(testCase, async (t: Test) => { try { await api.getStatusV1(parameters as any as GetStatusRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -714,7 +714,7 @@ test(testCase, async (t: Test) => { try { await api.getStatusV1(parameters as any as GetStatusRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -760,7 +760,7 @@ test(testCase, async (t: Test) => { try { await api.getSingleStatusV1(parameters as any as GetSingleStatusRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -788,7 +788,7 @@ test(testCase, async (t: Test) => { // eslint-disable-next-line prettier/prettier await api.getSingleStatusV1(parameters as any as GetSingleStatusRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, diff --git a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint-invalid-time.test.ts b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint-invalid-time.test.ts index dafd449acd0..df1d2f3a908 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint-invalid-time.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint-invalid-time.test.ts @@ -282,7 +282,7 @@ describe(testCase, () => { const resRefund = await api.refundV1(refundRequest); expect(resRefund.status).toEqual(400); } catch (err) { - const e = err as AxiosError + const e = err as AxiosError; expect(e?.response?.status).toEqual(400); } diff --git a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint.test.ts b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint.test.ts index 56f0e3d0020..f7d3f228508 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/refund-endpoint.test.ts @@ -586,7 +586,7 @@ test("Test invalid refund with invalid time", async (t: Test) => { const resRefund = await api.refundV1(refundRequest); t.equal(resRefund.status, 400, "response status is 400"); } catch (err) { - const e = err as AxiosError + const e = err as AxiosError; t.equal(e?.response?.status, 400, "response status is 400"); } diff --git a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/withdraw-endpoint-invalid-id.test.ts b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/withdraw-endpoint-invalid-id.test.ts index f921d1a6a01..c29e568aaa2 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/withdraw-endpoint-invalid-id.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu-erc20/src/test/typescript/integration/plugin-htlc-eth-besu-erc20/withdraw-endpoint-invalid-id.test.ts @@ -250,7 +250,7 @@ describe(testCase, () => { const resWithdraw = await api.withdrawV1(withdrawRequest); expect(resWithdraw.status).toEqual(400); } catch (err) { - const e = err as AxiosError + const e = err as AxiosError; expect(e?.response?.status).toEqual(400); } diff --git a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-single-status-endpoint-invalid.test.ts b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-single-status-endpoint-invalid.test.ts index 2c22b82fb67..3ca01b1b083 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-single-status-endpoint-invalid.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-single-status-endpoint-invalid.test.ts @@ -206,7 +206,7 @@ describe(testCase, () => { }); expect(res.status).toEqual(500); } catch (err) { - const e = err as AxiosError + const e = err as AxiosError; expect(e?.response?.status).toEqual(500); } }); diff --git a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-status-endpoint-invalid.test.ts b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-status-endpoint-invalid.test.ts index a22f0ef843c..6f290137778 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-status-endpoint-invalid.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/get-status-endpoint-invalid.test.ts @@ -208,7 +208,7 @@ describe(testCase, () => { }); expect(res.status).toEqual(500); } catch (err) { - const e = err as AxiosError + const e = err as AxiosError; expect(e?.response?.status).toEqual(500); } }); diff --git a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/openapi/openapi-validation.test.ts b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/openapi/openapi-validation.test.ts index 05c3c31e114..d205a66a2e2 100644 --- a/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/openapi/openapi-validation.test.ts +++ b/packages/cactus-test-plugin-htlc-eth-besu/src/test/typescript/integration/plugin-htlc-eth-besu/openapi/openapi-validation.test.ts @@ -209,7 +209,7 @@ test(testCase, async (t: Test) => { try { await api.initializeV1(parameters as unknown as InitializeRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, 400, @@ -240,14 +240,15 @@ test(testCase, async (t: Test) => { try { await api.initializeV1(parameters as unknown as InitializeRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, t2.equal( e?.response?.status, 400, `Endpoint ${fInitialize} with fake=4: response.status === 400 OK`, - )); + ), + ); const fields = e?.response?.data.map((param: { path: string }) => param.path.replace("/body/", ""), ); @@ -322,14 +323,15 @@ test(testCase, async (t: Test) => { try { await api.newContractV1(parameters as unknown as NewContractObj); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, t2.equal( e?.response?.status, 400, `Endpoint ${fNew} without required contractAddress: response.status === 400 OK`, - )); + ), + ); const fields = e?.response?.data.map((param: { path: string }) => param.path.replace("/body/", ""), ); @@ -361,14 +363,15 @@ test(testCase, async (t: Test) => { try { await api.newContractV1(parameters as unknown as NewContractObj); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, t2.equal( e?.response?.status, 400, `Endpoint ${fNew} with fake=4: response.status === 400 OK`, - )) + ), + ); const fields = e?.response?.data.map((param: { path: string }) => param.path.replace("/body/", ""), ); @@ -427,14 +430,15 @@ test(testCase, async (t: Test) => { try { await api.refundV1(parameters as unknown as RefundReq); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, t2.equal( e?.response?.status, 400, `Endpoint ${fRefund} without required id: response.status === 400 OK`, - )) + ), + ); const fields = e?.response?.data.map((param: { path: string }) => param.path.replace("/body/", ""), ); @@ -455,14 +459,15 @@ test(testCase, async (t: Test) => { try { await api.refundV1(parameters as unknown as RefundReq); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, t2.equal( e?.response?.status, 400, `Endpoint ${fRefund} with fake=4: response.status === 400 OK`, - )) + ), + ); const fields = e?.response?.data.map((param: { path: string }) => param.path.replace("/body/", ""), ); @@ -538,14 +543,15 @@ test(testCase, async (t: Test) => { try { await api.withdrawV1(parameters as unknown as WithdrawReq); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, t2.equal( e?.response?.status, 400, `Endpoint ${fWithdraw} without required id: response.status === 400 OK`, - )) + ), + ); const fields = e?.response?.data.map((param: { path: string }) => param.path.replace("/body/", ""), ); @@ -569,14 +575,15 @@ test(testCase, async (t: Test) => { try { await api.withdrawV1(parameters as unknown as WithdrawReq); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, t2.equal( e?.response?.status, 400, `Endpoint ${fWithdraw} with fake=4: response.status === 400 OK`, - )) + ), + ); const fields = e?.response?.data.map((param: { path: string }) => param.path.replace("/body/", ""), ); @@ -661,14 +668,15 @@ test(testCase, async (t: Test) => { try { await api.getStatusV1(parameters as unknown as GetStatusRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, t2.equal( e?.response?.status, 400, `Endpoint ${fStatus} without required ids: response.status === 400 OK`, - )) + ), + ); const fields = e?.response?.data.map((param: { path: string }) => param.path.replace("/body/", ""), ); @@ -690,14 +698,15 @@ test(testCase, async (t: Test) => { try { await api.getStatusV1(parameters as unknown as GetStatusRequest); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, t2.equal( e?.response?.status, 400, `Endpoint ${fStatus} with fake=4: response.status === 400 OK`, - )) + ), + ); const fields = e?.response?.data.map((param: { path: string }) => param.path.replace("/body/", ""), ); @@ -782,14 +791,15 @@ test(testCase, async (t: Test) => { parameters as unknown as GetSingleStatusRequest, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, t2.equal( e?.response?.status, 400, `Endpoint ${fSingleStatus} without required id: response.status === 400 OK`, - )) + ), + ); const fields = e?.response?.data.map((param: { path: string }) => param.path.replace("/body/", ""), ); @@ -813,14 +823,15 @@ test(testCase, async (t: Test) => { parameters as unknown as GetSingleStatusRequest, ); } catch (err) { - const e = err as AxiosError<{ path: string }[]> + const e = err as AxiosError<{ path: string }[]>; t2.equal( e?.response?.status, t2.equal( e?.response?.status, 400, `Endpoint ${fSingleStatus} with fake=4: response.status === 400 OK`, - )) + ), + ); const fields = e?.response?.data.map((param: { path: string }) => param.path.replace("/body/", ""), ); diff --git a/packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/v21-sign-transaction-endpoint.test.ts b/packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/v21-sign-transaction-endpoint.test.ts index c93b4061845..9bb157e68e7 100644 --- a/packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/v21-sign-transaction-endpoint.test.ts +++ b/packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/v21-sign-transaction-endpoint.test.ts @@ -191,7 +191,7 @@ test(testCase, async (t: Test) => { }; await api.signTransactionV1(notFoundRequest); } catch (err) { - const e = err as AxiosError + const e = err as AxiosError; t.equal(e.response?.status, 404, "HTTP response status are equal"); t.equal( e.response?.statusText, diff --git a/packages/cactus-test-tooling/src/main/typescript/fabric/fabric-test-ledger-v1.ts b/packages/cactus-test-tooling/src/main/typescript/fabric/fabric-test-ledger-v1.ts index f1b544b5bd6..eaf631cb80b 100644 --- a/packages/cactus-test-tooling/src/main/typescript/fabric/fabric-test-ledger-v1.ts +++ b/packages/cactus-test-tooling/src/main/typescript/fabric/fabric-test-ledger-v1.ts @@ -469,17 +469,17 @@ export class FabricTestLedgerV1 implements ITestLedger { const connectionProfilePath = orgName === "org1" || orgName === "org2" ? path.join( - "fabric-samples/test-network", - "organizations/peerOrganizations", - orgName + ".example.com", - "connection-" + orgName + ".json", - ) + "fabric-samples/test-network", + "organizations/peerOrganizations", + orgName + ".example.com", + "connection-" + orgName + ".json", + ) : path.join( - "add-org-" + orgName, - "organizations/peerOrganizations", - orgName + ".example.com", - "connection-" + orgName + ".json", - ); + "add-org-" + orgName, + "organizations/peerOrganizations", + orgName + ".example.com", + "connection-" + orgName + ".json", + ); const peer0Name = `peer0.${orgName}.example.com`; const peer1Name = `peer1.${orgName}.example.com`; const cInfo = await this.getContainerInfo(); diff --git a/tools/generate-sbom.ts b/tools/generate-sbom.ts index d7b63f3b4a9..c4e2bd6f545 100644 --- a/tools/generate-sbom.ts +++ b/tools/generate-sbom.ts @@ -259,6 +259,6 @@ export async function generateSBoM(req: { } } -export class ManifestParseError extends RuntimeError { } +export class ManifestParseError extends RuntimeError {} main(process.argv, process.env); diff --git a/weaver/core/drivers/fabric-driver/server/server.ts b/weaver/core/drivers/fabric-driver/server/server.ts index 2730fdd142a..18c531d918a 100644 --- a/weaver/core/drivers/fabric-driver/server/server.ts +++ b/weaver/core/drivers/fabric-driver/server/server.ts @@ -438,9 +438,9 @@ const configSetup = async () => { const walletPath = process.env.WALLET_PATH ? process.env.WALLET_PATH : path.join( - process.cwd(), - `wallet-${process.env.NETWORK_NAME ? process.env.NETWORK_NAME : "network1"}`, - ); + process.cwd(), + `wallet-${process.env.NETWORK_NAME ? process.env.NETWORK_NAME : "network1"}`, + ); if (process.env.CONNECTION_PROFILE) { await walletSetup(walletPath, process.env.CONNECTION_PROFILE); } else {