Updates
This commit is contained in:
@@ -18,6 +18,7 @@ type Param = {
|
||||
isPrivate?: boolean;
|
||||
};
|
||||
user_id?: string | number;
|
||||
useDefault?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -27,8 +28,9 @@ export default async function uploadImage({
|
||||
key,
|
||||
payload,
|
||||
user_id,
|
||||
useDefault,
|
||||
}: Param): Promise<Return> {
|
||||
const grabedHostNames = grabHostNames();
|
||||
const grabedHostNames = grabHostNames({ useDefault });
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
|
||||
try {
|
||||
|
||||
@@ -22,6 +22,7 @@ type Param = {
|
||||
isPrivate?: boolean;
|
||||
};
|
||||
user_id?: string | number;
|
||||
useDefault?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -31,8 +32,9 @@ export default async function uploadImage({
|
||||
key,
|
||||
payload,
|
||||
user_id,
|
||||
useDefault,
|
||||
}: Param): Promise<FunctionReturn> {
|
||||
const grabedHostNames = grabHostNames();
|
||||
const grabedHostNames = grabHostNames({ useDefault });
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
|
||||
try {
|
||||
|
||||
@@ -24,10 +24,11 @@ const grabApiCred: CheckApiCredentialsFn = ({
|
||||
);
|
||||
|
||||
const ApiJSON = decrypt({ encryptedString: key });
|
||||
/** @type {import("../../types").ApiKeyObject} */
|
||||
|
||||
const ApiObject: import("../../types").ApiKeyObject = JSON.parse(
|
||||
ApiJSON || ""
|
||||
);
|
||||
|
||||
const isApiKeyValid = fs.existsSync(
|
||||
`${allowedKeysPath}/${ApiObject.sign}`
|
||||
);
|
||||
@@ -50,7 +51,7 @@ const grabApiCred: CheckApiCredentialsFn = ({
|
||||
.includes(String(table));
|
||||
if (isTableAllowed) return ApiObject;
|
||||
return null;
|
||||
} catch (/** @type {any} */ error: any) {
|
||||
} catch (error: any) {
|
||||
console.log(`api-cred ERROR: ${error.message}`);
|
||||
return { error: `api-cred ERROR: ${error.message}` };
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ type GrabHostNamesReturn = {
|
||||
type Param = {
|
||||
userId?: string | number;
|
||||
env?: { [k: string]: string };
|
||||
remoteHost?: string;
|
||||
remoteHostPort?: string;
|
||||
useDefault?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -26,10 +29,15 @@ export default function grabHostNames(param?: Param): GrabHostNamesReturn {
|
||||
const scheme = finalEnv["DSQL_HTTP_SCHEME"];
|
||||
const localHost = finalEnv["DSQL_LOCAL_HOST"];
|
||||
const localHostPort = finalEnv["DSQL_LOCAL_HOST_PORT"];
|
||||
const remoteHost = finalEnv["DSQL_API_REMOTE_HOST"]?.match(/.*\..*/)
|
||||
|
||||
const remoteHost = param?.useDefault
|
||||
? undefined
|
||||
: finalEnv["DSQL_API_REMOTE_HOST"]?.match(/.*\..*/)
|
||||
? finalEnv["DSQL_API_REMOTE_HOST"]
|
||||
: undefined;
|
||||
const remoteHostPort = finalEnv["DSQL_API_REMOTE_HOST_PORT"]?.match(/./)
|
||||
const remoteHostPort = param?.useDefault
|
||||
? undefined
|
||||
: finalEnv["DSQL_API_REMOTE_HOST_PORT"]?.match(/./)
|
||||
? finalEnv["DSQL_API_REMOTE_HOST_PORT"]
|
||||
: undefined;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user