31 lines
822 B
TypeScript
31 lines
822 B
TypeScript
|
require("dotenv").config({ path: "./../.env" });
|
||
|
import mysql from "serverless-mysql";
|
||
|
import grabDbSSL from "../utils/backend/grabDbSSL";
|
||
|
|
||
|
/**
|
||
|
* # 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 () => {
|
||
|
const connection = global.DSQL_DB_CONN;
|
||
|
|
||
|
try {
|
||
|
const result = await connection.query(
|
||
|
"SELECT id,first_name,last_name FROM users LIMIT 3"
|
||
|
);
|
||
|
console.log("Connection Query Success =>", result);
|
||
|
} catch (error: any) {
|
||
|
console.log("Connection query ERROR =>", error.message);
|
||
|
} finally {
|
||
|
connection.end();
|
||
|
process.exit();
|
||
|
}
|
||
|
})();
|