This commit is contained in:
Benjamin Toby
2025-01-20 08:12:01 +01:00
parent 3dd1d08a5b
commit fdd3913f4f
11 changed files with 55 additions and 22 deletions
+21 -1
View File
@@ -23,9 +23,29 @@ type Param = {
* # Grab General CONNECTION for DSQL
*/
export default function grabDSQLConnection(param?: Param): ServerlessMysql {
if (param?.local) {
return (
global.DSQL_DB_CONN ||
mysql({
config: {
host: process.env.DSQL_DB_HOST,
user: process.env.DSQL_DB_USERNAME,
password: process.env.DSQL_DB_PASSWORD,
database: param?.noDb
? undefined
: process.env.DSQL_DB_NAME,
port: process.env.DSQL_DB_PORT
? Number(process.env.DSQL_DB_PORT)
: undefined,
charset: "utf8mb4",
},
})
);
}
if (param?.ro) {
return (
DSQL_READ_ONLY_DB_CONN ||
global.DSQL_READ_ONLY_DB_CONN ||
mysql({
config: {
host: process.env.DSQL_DB_HOST,