This commit is contained in:
Benjamin Toby
2025-04-23 13:45:48 +01:00
parent cd6bfdfc67
commit d78e44c98d
12 changed files with 42 additions and 21 deletions
+2 -1
View File
@@ -15,9 +15,10 @@ type Param = {
isPrivate?: boolean;
};
user_id?: string | number;
useDefault?: boolean;
};
/**
* # Upload File via API
*/
export default function uploadImage({ key, payload, user_id, }: Param): Promise<Return>;
export default function uploadImage({ key, payload, user_id, useDefault, }: Param): Promise<Return>;
export {};
+2 -2
View File
@@ -18,9 +18,9 @@ const grab_host_names_1 = __importDefault(require("../utils/grab-host-names"));
* # Upload File via API
*/
function uploadImage(_a) {
return __awaiter(this, arguments, void 0, function* ({ key, payload, user_id, }) {
return __awaiter(this, arguments, void 0, function* ({ key, payload, user_id, useDefault, }) {
var _b;
const grabedHostNames = (0, grab_host_names_1.default)();
const grabedHostNames = (0, grab_host_names_1.default)({ useDefault });
const { host, port, scheme } = grabedHostNames;
try {
/**
+2 -1
View File
@@ -17,9 +17,10 @@ type Param = {
isPrivate?: boolean;
};
user_id?: string | number;
useDefault?: boolean;
};
/**
* # Upload Image via API
*/
export default function uploadImage({ key, payload, user_id, }: Param): Promise<FunctionReturn>;
export default function uploadImage({ key, payload, user_id, useDefault, }: Param): Promise<FunctionReturn>;
export {};
+2 -2
View File
@@ -19,9 +19,9 @@ const grab_host_names_1 = __importDefault(require("../utils/grab-host-names"));
* # Upload Image via API
*/
function uploadImage(_a) {
return __awaiter(this, arguments, void 0, function* ({ key, payload, user_id, }) {
return __awaiter(this, arguments, void 0, function* ({ key, payload, user_id, useDefault, }) {
var _b;
const grabedHostNames = (0, grab_host_names_1.default)();
const grabedHostNames = (0, grab_host_names_1.default)({ useDefault });
const { host, port, scheme } = grabedHostNames;
try {
/**
+1 -2
View File
@@ -19,7 +19,6 @@ const grabApiCred = ({ key, database, table, user_id, media, }) => {
if (!allowedKeysPath)
throw new Error("process.env.DSQL_API_KEYS_PATH variable not found");
const ApiJSON = (0, decrypt_1.default)({ encryptedString: key });
/** @type {import("../../types").ApiKeyObject} */
const ApiObject = JSON.parse(ApiJSON || "");
const isApiKeyValid = fs_1.default.existsSync(`${allowedKeysPath}/${ApiObject.sign}`);
if (String(ApiObject.user_id) !== String(user_id))
@@ -42,7 +41,7 @@ const grabApiCred = ({ key, database, table, user_id, media, }) => {
return ApiObject;
return null;
}
catch ( /** @type {any} */error) {
catch (error) {
console.log(`api-cred ERROR: ${error.message}`);
return { error: `api-cred ERROR: ${error.message}` };
}
+3
View File
@@ -11,6 +11,9 @@ type Param = {
env?: {
[k: string]: string;
};
remoteHost?: string;
remoteHostPort?: string;
useDefault?: boolean;
};
/**
* # Grab Names For Query
+10 -6
View File
@@ -17,12 +17,16 @@ function grabHostNames(param) {
const scheme = finalEnv["DSQL_HTTP_SCHEME"];
const localHost = finalEnv["DSQL_LOCAL_HOST"];
const localHostPort = finalEnv["DSQL_LOCAL_HOST_PORT"];
const remoteHost = ((_a = finalEnv["DSQL_API_REMOTE_HOST"]) === null || _a === void 0 ? void 0 : _a.match(/.*\..*/))
? finalEnv["DSQL_API_REMOTE_HOST"]
: undefined;
const remoteHostPort = ((_b = finalEnv["DSQL_API_REMOTE_HOST_PORT"]) === null || _b === void 0 ? void 0 : _b.match(/./))
? finalEnv["DSQL_API_REMOTE_HOST_PORT"]
: undefined;
const remoteHost = (param === null || param === void 0 ? void 0 : param.useDefault)
? undefined
: ((_a = finalEnv["DSQL_API_REMOTE_HOST"]) === null || _a === void 0 ? void 0 : _a.match(/.*\..*/))
? finalEnv["DSQL_API_REMOTE_HOST"]
: undefined;
const remoteHostPort = (param === null || param === void 0 ? void 0 : param.useDefault)
? undefined
: ((_b = finalEnv["DSQL_API_REMOTE_HOST_PORT"]) === null || _b === void 0 ? void 0 : _b.match(/./))
? finalEnv["DSQL_API_REMOTE_HOST_PORT"]
: undefined;
return {
host: remoteHost || localHost || "datasquirel.com",
port: remoteHostPort || localHostPort || 443,