This commit is contained in:
Benjamin Toby 2024-12-04 06:38:30 +01:00
parent b047d6557c
commit 6df20790f4
3 changed files with 33 additions and 7 deletions

View File

@ -1229,3 +1229,25 @@ export type ApiConnectBody = {
type: "pull" | "push"; type: "pull" | "push";
user_id?: string | number; user_id?: string | number;
}; };
export type SuUserType = {
email: string;
password: string;
authKey: string;
logged_in_status: boolean;
date: number;
};
export type MariadbRemoteServerObject = {
host: string;
port: number;
primary?: boolean;
loadBalanced?: boolean;
users?: MariadbRemoteServerUserObject[];
};
export type MariadbRemoteServerUserObject = {
name: string;
password: string;
host: string;
};

View File

@ -2,7 +2,7 @@
* *
* @param {string | null | number} string * @param {string | null | number} string
* @param {(this: any, key: string, value: any) => any} [reviver] * @param {(this: any, key: string, value: any) => any} [reviver]
* @returns {{ [key: string]: any } | { [key: string]: any }[] | undefined} * @returns {Object<string, any> | Object<string, any>[] | undefined}
*/ */
function parse(string, reviver) { function parse(string, reviver) {
if (!string) return undefined; if (!string) return undefined;
@ -18,7 +18,7 @@ function parse(string, reviver) {
/** /**
* *
* @param {any} value * @param {any} value
* @param {(this: any, key: string, value: any) => any} [replacer] * @param {((this: any, key: string, value: any) => any) | null} [replacer]
* @param { string | number } [space] * @param { string | number } [space]
* @returns {string | undefined} * @returns {string | undefined}
*/ */

View File

@ -96,6 +96,10 @@ async function post({
const reqPayload = reqPayloadString; const reqPayload = reqPayloadString;
const requPath = `/api/query/${
user_id || grabedHostNames.user_id
}/post`;
const httpsRequest = scheme.request( const httpsRequest = scheme.request(
{ {
method: "POST", method: "POST",
@ -109,7 +113,7 @@ async function post({
}, },
port, port,
hostname: host, hostname: host,
path: `/api/query/${user_id || grabedHostNames.user_id}/post`, path: requPath,
}, },
/** /**
@ -127,14 +131,14 @@ async function post({
response.on("end", function () { response.on("end", function () {
try { try {
resolve(JSON.parse(str)); resolve(JSON.parse(str));
} catch (error) { } catch (/** @type {any} */ error) {
console.log(error); console.log("Route ERROR:", error.message);
console.log("Fetched Payload =>", str);
resolve({ resolve({
success: false, success: false,
payload: null, payload: null,
error: error, error: error.message,
errPayload: str,
}); });
} }
}); });