import mysql from "serverless-mysql"; import grabDbSSL from "../grabDbSSL"; let NO_DB = mysql({ config: { host: process.env.DSQL_DB_HOST, user: process.env.DSQL_DB_USERNAME, password: process.env.DSQL_DB_PASSWORD, charset: "utf8mb4", ssl: grabDbSSL(), }, }); /** * # DSQL user read-only DB handler */ export default function NO_DB_HANDLER(...args: any[]) { try { return new Promise((resolve, reject) => { NO_DB.query(...args) .then((results) => { NO_DB.end(); resolve(JSON.parse(JSON.stringify(results))); }) .catch((err) => { NO_DB.end(); resolve({ error: err.message, sql: err.sql, }); }); }); } catch (error: any) { return { success: false, error: error.message, }; } }