Updates
This commit is contained in:
+4
-1
@@ -1,10 +1,12 @@
|
||||
import https from "https";
|
||||
import http from "http";
|
||||
type GrabHostNamesReturn = {
|
||||
import { APIConnectionOptions } from "../types";
|
||||
export type GrabHostNamesReturn = {
|
||||
host: string;
|
||||
port: number | string;
|
||||
scheme: typeof http | typeof https;
|
||||
user_id: string | number;
|
||||
apiKey?: string;
|
||||
};
|
||||
type Param = {
|
||||
userId?: string | number;
|
||||
@@ -14,6 +16,7 @@ type Param = {
|
||||
remoteHost?: string;
|
||||
remoteHostPort?: string;
|
||||
useDefault?: boolean;
|
||||
apiConnectionConfig?: APIConnectionOptions;
|
||||
};
|
||||
/**
|
||||
* # Grab Names For Query
|
||||
|
||||
+21
-10
@@ -11,26 +11,37 @@ const http_1 = __importDefault(require("http"));
|
||||
* # Grab Names For Query
|
||||
*/
|
||||
function grabHostNames(param) {
|
||||
var _a, _b;
|
||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
||||
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 scheme = ((_a = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _a === void 0 ? void 0 : _a.scheme) || finalEnv["DSQL_HTTP_SCHEME"];
|
||||
const localHost = ((_b = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _b === void 0 ? void 0 : _b.isLocalhost)
|
||||
? "localhost"
|
||||
: finalEnv["DSQL_LOCAL_HOST"];
|
||||
const localHostPort = ((_c = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _c === void 0 ? void 0 : _c.localhostPort) ||
|
||||
finalEnv["DSQL_LOCAL_HOST_PORT"];
|
||||
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;
|
||||
: ((_d = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _d === void 0 ? void 0 : _d.remoteHost)
|
||||
? (_e = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _e === void 0 ? void 0 : _e.remoteHost
|
||||
: ((_f = finalEnv["DSQL_API_REMOTE_HOST"]) === null || _f === void 0 ? void 0 : _f.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;
|
||||
: ((_g = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _g === void 0 ? void 0 : _g.remoteHostPort)
|
||||
? (_h = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _h === void 0 ? void 0 : _h.remoteHostPort
|
||||
: ((_j = finalEnv["DSQL_API_REMOTE_HOST_PORT"]) === null || _j === void 0 ? void 0 : _j.match(/./))
|
||||
? finalEnv["DSQL_API_REMOTE_HOST_PORT"]
|
||||
: undefined;
|
||||
return {
|
||||
host: remoteHost || localHost || "www.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(finalEnv["DSQL_API_USER_ID"] || 0),
|
||||
apiKey: ((_k = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _k === void 0 ? void 0 : _k.apiKey) ||
|
||||
process.env.DSQL_FULL_ACCESS_API_KEY ||
|
||||
process.env.DSQL_API_KEY ||
|
||||
process.env.DSQL_READ_ONLY_API_KEY,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user