32 lines
825 B
TypeScript
32 lines
825 B
TypeScript
import mysql from "serverless-mysql";
|
|
import grabDbSSL from "../grabDbSSL";
|
|
|
|
/**
|
|
* # DSQL user read-only DB handler
|
|
*/
|
|
export default function NO_DB_HANDLER(...args: any[]) {
|
|
const NO_DB = global.DSQL_DB_CONN;
|
|
|
|
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,
|
|
};
|
|
}
|
|
}
|