dsql-admin/dsql-app/package-shared/shell/test-external-server.ts

39 lines
981 B
TypeScript
Raw Normal View History

2024-12-06 13:24:26 +00:00
require("dotenv").config({ path: "./.env" });
2025-01-14 15:27:08 +00:00
import grabDSQLConnection from "../utils/grab-dsql-connection";
2024-12-06 13:24:26 +00:00
/**
* # Main DB Handler Function
* @async
*
* @param {object} params
* @param {string} params.query
* @param {string[] | object} [params.values]
* @param {string} [params.database]
*
* @returns {Promise<object|null>}
*/
(async () => {
2025-01-14 15:27:08 +00:00
const CONNECTION = grabDSQLConnection({ noDb: true });
2024-12-06 13:24:26 +00:00
/**
* Switch Database
*
* @description If a database is provided, switch to it
*/
try {
2025-01-14 15:27:08 +00:00
const result = await CONNECTION.query("SHOW DATABASES");
2024-12-06 13:24:26 +00:00
const parsedResults = JSON.parse(JSON.stringify(result));
console.log("parsedResults =>", parsedResults);
2025-01-13 08:00:21 +00:00
} catch (error: any) {
2025-02-19 19:38:56 +00:00
global.ERROR_CALLBACK?.(
`Error Testing External Server`,
error as Error
);
2024-12-06 13:24:26 +00:00
} finally {
2025-01-14 15:27:08 +00:00
CONNECTION?.end();
2024-12-06 13:24:26 +00:00
process.exit();
}
})();