mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-16 01:24:05 -08:00
85aa560a5d
Co-authored-by: Michael Kret <michael.k@radency.com>
35 lines
768 B
TypeScript
35 lines
768 B
TypeScript
import type {
|
|
ICredentialsDecrypted,
|
|
ICredentialTestFunctions,
|
|
INodeCredentialTestResult,
|
|
} from 'n8n-workflow';
|
|
|
|
import { createPool } from '../transport';
|
|
import type { MysqlNodeCredentials } from '../helpers/interfaces';
|
|
|
|
export async function mysqlConnectionTest(
|
|
this: ICredentialTestFunctions,
|
|
credential: ICredentialsDecrypted,
|
|
): Promise<INodeCredentialTestResult> {
|
|
const credentials = credential.data as MysqlNodeCredentials;
|
|
|
|
const pool = await createPool.call(this, credentials);
|
|
|
|
try {
|
|
const connection = await pool.getConnection();
|
|
connection.release();
|
|
} catch (error) {
|
|
return {
|
|
status: 'Error',
|
|
message: error.message,
|
|
};
|
|
} finally {
|
|
await pool.end();
|
|
}
|
|
|
|
return {
|
|
status: 'OK',
|
|
message: 'Connection successful!',
|
|
};
|
|
}
|