From bd74f8eef74d9ac4c90d33e8194fe0bb40b7f9e8 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 15 May 2023 17:08:23 +0100 Subject: [PATCH] Updating testConnection usage. --- .../server/src/api/controllers/datasource.ts | 16 ++++++++++++---- packages/types/src/api/web/app/datasource.ts | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/server/src/api/controllers/datasource.ts b/packages/server/src/api/controllers/datasource.ts index e6866d528c..363cde2e6f 100644 --- a/packages/server/src/api/controllers/datasource.ts +++ b/packages/server/src/api/controllers/datasource.ts @@ -128,12 +128,20 @@ export async function verify( ) { const datasource = ctx.request.body.datasource const connector = (await getConnector(datasource)) as IntegrationBase - if (!connector.connection) { + if (!connector.testConnection) { ctx.throw(400, "Connection information verification not supported") } - const connectionInfo = await connector.connection() - ctx.body = { - connected: connectionInfo.connected, + const response = await connector.testConnection() + + if (typeof response === "boolean") { + ctx.body = { + connected: response, + } + } else { + ctx.body = { + connected: false, + error: response.error + } } } diff --git a/packages/types/src/api/web/app/datasource.ts b/packages/types/src/api/web/app/datasource.ts index 36e081d9f6..983fd45b92 100644 --- a/packages/types/src/api/web/app/datasource.ts +++ b/packages/types/src/api/web/app/datasource.ts @@ -20,6 +20,7 @@ export interface VerifyDatasourceRequest { export interface VerifyDatasourceResponse { connected: boolean + error?: string } export interface UpdateDatasourceRequest extends Datasource {