This commit is contained in:
Benjamin Toby
2025-04-23 14:21:14 +01:00
parent d78e44c98d
commit 2ad17ae682
7 changed files with 73 additions and 7 deletions
+20 -1
View File
@@ -5,6 +5,7 @@ import fs from "fs";
import grabHostNames from "../utils/grab-host-names";
import apiPost from "../functions/api/query/post";
import { PostDataPayload, PostReturn } from "../types";
import debugLog from "../utils/logging/debug-log";
type Param = {
key?: string;
@@ -14,6 +15,7 @@ type Param = {
tableName?: string;
user_id?: boolean;
forceLocal?: boolean;
debug?: boolean;
};
/**
@@ -27,10 +29,19 @@ export default async function post({
tableName,
user_id,
forceLocal,
debug,
}: Param): Promise<PostReturn> {
const grabedHostNames = grabHostNames();
const { host, port, scheme } = grabedHostNames;
if (debug) {
debugLog({
log: grabedHostNames,
addTime: true,
label: "grabedHostNames",
});
}
/**
* Check for local DB settings
*
@@ -57,6 +68,13 @@ export default async function post({
dbSchema = JSON.parse(fs.readFileSync(localDbSchemaPath, "utf8"));
} catch (error) {}
if (debug) {
debugLog({
log: "Using Local DB ...",
addTime: true,
});
}
return await apiPost({
dbFullName: DSQL_DB_NAME,
query,
@@ -64,6 +82,7 @@ export default async function post({
queryValues,
tableName,
forceLocal,
debug,
});
}
@@ -132,7 +151,7 @@ export default async function post({
response.on("end", function () {
try {
resolve(JSON.parse(str));
} catch (/** @type {any} */ error: any) {
} catch (error: any) {
console.log("Route ERROR:", error.message);
resolve({