Updates
This commit is contained in:
@@ -17,15 +17,28 @@ export default async function dbHandler({
|
||||
query,
|
||||
values,
|
||||
}: Param): Promise<any[] | object | null> {
|
||||
let connection = global.DSQL_DB_CONN;
|
||||
const CONNECTION =
|
||||
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: process.env.DSQL_DB_NAME,
|
||||
port: process.env.DSQL_DB_PORT
|
||||
? Number(process.env.DSQL_DB_PORT)
|
||||
: undefined,
|
||||
charset: "utf8mb4",
|
||||
},
|
||||
});
|
||||
|
||||
let results;
|
||||
|
||||
try {
|
||||
if (query && values) {
|
||||
results = await connection.query(query, values);
|
||||
results = await CONNECTION.query(query, values);
|
||||
} else {
|
||||
results = await connection.query(query);
|
||||
results = await CONNECTION.query(query);
|
||||
}
|
||||
} catch (/** @type {any} */ error: any) {
|
||||
if (process.env.FIRST_RUN) {
|
||||
@@ -34,7 +47,7 @@ export default async function dbHandler({
|
||||
|
||||
console.log("ERROR in dbHandler =>", error.message);
|
||||
console.log(error);
|
||||
console.log(connection.config());
|
||||
console.log(CONNECTION.config());
|
||||
|
||||
fs.appendFileSync(
|
||||
path.resolve(__dirname, "../.tmp/dbErrorLogs.txt"),
|
||||
@@ -43,7 +56,7 @@ export default async function dbHandler({
|
||||
);
|
||||
results = null;
|
||||
} finally {
|
||||
await connection?.end();
|
||||
await CONNECTION?.end();
|
||||
}
|
||||
|
||||
if (results) {
|
||||
|
||||
Reference in New Issue
Block a user