Updating testConnection usage.

This commit is contained in:
mike12345567 2023-05-15 17:08:23 +01:00
parent 571987a2ce
commit bd74f8eef7
2 changed files with 13 additions and 4 deletions

View File

@ -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
}
}
}

View File

@ -20,6 +20,7 @@ export interface VerifyDatasourceRequest {
export interface VerifyDatasourceResponse {
connected: boolean
error?: string
}
export interface UpdateDatasourceRequest extends Datasource {