diff --git a/package-shared/types/index.d.ts b/package-shared/types/index.d.ts index d6adf78..565ec5e 100644 --- a/package-shared/types/index.d.ts +++ b/package-shared/types/index.d.ts @@ -1229,3 +1229,25 @@ export type ApiConnectBody = { type: "pull" | "push"; 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; +}; diff --git a/package-shared/utils/ejson.js b/package-shared/utils/ejson.js index 4630439..567f452 100644 --- a/package-shared/utils/ejson.js +++ b/package-shared/utils/ejson.js @@ -2,7 +2,7 @@ * * @param {string | null | number} string * @param {(this: any, key: string, value: any) => any} [reviver] - * @returns {{ [key: string]: any } | { [key: string]: any }[] | undefined} + * @returns {Object | Object[] | undefined} */ function parse(string, reviver) { if (!string) return undefined; @@ -18,7 +18,7 @@ function parse(string, reviver) { /** * * @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] * @returns {string | undefined} */ diff --git a/utils/post.js b/utils/post.js index 929b452..f48daee 100644 --- a/utils/post.js +++ b/utils/post.js @@ -96,6 +96,10 @@ async function post({ const reqPayload = reqPayloadString; + const requPath = `/api/query/${ + user_id || grabedHostNames.user_id + }/post`; + const httpsRequest = scheme.request( { method: "POST", @@ -109,7 +113,7 @@ async function post({ }, port, hostname: host, - path: `/api/query/${user_id || grabedHostNames.user_id}/post`, + path: requPath, }, /** @@ -127,14 +131,14 @@ async function post({ response.on("end", function () { try { resolve(JSON.parse(str)); - } catch (error) { - console.log(error); - console.log("Fetched Payload =>", str); + } catch (/** @type {any} */ error) { + console.log("Route ERROR:", error.message); resolve({ success: false, payload: null, - error: error, + error: error.message, + errPayload: str, }); } });