This commit is contained in:
Benjamin Toby
2025-04-17 11:42:53 +01:00
parent ba1a4aeeb8
commit ee23d71b66
11 changed files with 74 additions and 23 deletions
+3
View File
@@ -8,6 +8,9 @@ type GrabHostNamesReturn = {
};
type Param = {
userId?: string | number;
env?: {
[k: string]: string;
};
};
/**
* # Grab Names For Query
+10 -8
View File
@@ -12,19 +12,21 @@ const http_1 = __importDefault(require("http"));
*/
function grabHostNames(param) {
var _a, _b;
const scheme = process.env.DSQL_HTTP_SCHEME;
const localHost = process.env.DSQL_LOCAL_HOST;
const localHostPort = process.env.DSQL_LOCAL_HOST_PORT;
const remoteHost = ((_a = process.env.DSQL_API_REMOTE_HOST) === null || _a === void 0 ? void 0 : _a.match(/.*\..*/))
? process.env.DSQL_API_REMOTE_HOST
const finalEnv = (param === null || param === void 0 ? void 0 : param.env)
? Object.assign(Object.assign({}, process.env), param.env) : process.env;
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 = process.env.DSQL_API_REMOTE_HOST_PORT) === null || _b === void 0 ? void 0 : _b.match(/./))
? process.env.DSQL_API_REMOTE_HOST_PORT
const remoteHostPort = ((_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,
scheme: (scheme === null || scheme === void 0 ? void 0 : scheme.match(/^http$/i)) ? http_1.default : https_1.default,
user_id: (param === null || param === void 0 ? void 0 : param.userId) || String(process.env.DSQL_API_USER_ID || 0),
user_id: (param === null || param === void 0 ? void 0 : param.userId) || String(finalEnv["DSQL_API_USER_ID"] || 0),
};
}