23 lines
701 B
TypeScript
23 lines
701 B
TypeScript
import mariadb, { Connection, ConnectionConfig } from "mariadb";
|
|
import grabDbSSL from "./backend/grabDbSSL";
|
|
import { DsqlConnectionParam } from "../types";
|
|
import grabDSQLConnectionConfig from "./grab-dsql-connection-config";
|
|
import serverlessMysql, { ServerlessMysql } from "serverless-mysql";
|
|
|
|
/**
|
|
* # Grab General CONNECTION for DSQL
|
|
*/
|
|
export default async function grabDSQLConnection(
|
|
param?: DsqlConnectionParam
|
|
): Promise<ServerlessMysql> {
|
|
const config = grabDSQLConnectionConfig(param);
|
|
|
|
try {
|
|
const sql = serverlessMysql(config);
|
|
return sql;
|
|
} catch (error) {
|
|
console.log(`Error Grabbing DSQL Connection =>`, config);
|
|
throw error;
|
|
}
|
|
}
|