require("dotenv").config({ path: "./../.env" });
import mysql from "serverless-mysql";
import grabDSQLConnection from "../utils/grab-dsql-connection";

/**
 * # 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 = grabDSQLConnection();

    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();
    }
})();
