This commit is contained in:
Benjamin Toby
2024-12-17 18:39:50 +01:00
parent 4b8e8de71f
commit a2ba913340
5 changed files with 16 additions and 10 deletions
+4 -2
View File
@@ -4,7 +4,7 @@ const fs = require("fs");
const decrypt = require("../dsql/decrypt");
/** @type {import("../../types").CheckApiCredentialsFn} */
const grabApiCred = ({ key, database, table, user_id }) => {
const grabApiCred = ({ key, database, table, user_id, media }) => {
if (!key) return null;
if (!user_id) return null;
@@ -27,6 +27,8 @@ const grabApiCred = ({ key, database, table, user_id }) => {
if (!isApiKeyValid) return null;
if (!ApiObject.target_database) return ApiObject;
if (media) return ApiObject;
if (!database && ApiObject.target_database) return null;
const isDatabaseAllowed = ApiObject.target_database
?.split(",")
@@ -41,7 +43,7 @@ const grabApiCred = ({ key, database, table, user_id }) => {
return null;
} catch (/** @type {any} */ error) {
console.log(`api-cred ERROR: ${error.message}`);
return null;
return { error: `api-cred ERROR: ${error.message}` };
}
};
@@ -172,7 +172,7 @@ function sqlGenerator({ tableName, genObject }) {
return str;
})();
if (sqlSearhString) {
if (sqlSearhString?.[0] && sqlSearhString.find((str) => str)) {
const stringOperator = genObject?.searchOperator || "AND";
queryString += ` WHERE ${sqlSearhString.join(` ${stringOperator} `)} `;
}