diff --git a/client/media/client.js b/client/media/client.js index 72f7431..63543f7 100644 --- a/client/media/client.js +++ b/client/media/client.js @@ -1,22 +1,10 @@ -/** - * ============================================================================== - * Imports - * ============================================================================== - */ import imageInputFileToBase64 from "./imageInputFileToBase64"; import imageInputToBase64 from "./imageInputToBase64"; -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ -/** ****************************************************************************** */ - /** - * ============================================================================== + * ========================== * Media Functions Object - * ============================================================================== + * ========================== */ const media = { imageInputToBase64: imageInputToBase64, @@ -24,9 +12,9 @@ const media = { }; /** - * ============================================================================== + * ========================== * Media Functions Object - * ============================================================================== + * ========================== */ const auth = { imageInputToBase64: imageInputToBase64, @@ -34,16 +22,12 @@ const auth = { }; /** - * ============================================================================== + * ========================== * Main Export - * ============================================================================== + * ========================== */ const datasquirelClient = { media: media, }; export default datasquirelClient; - -/** ********************************************** */ -/** ********************************************** */ -/** ********************************************** */ diff --git a/package.json b/package.json index e07883e..aefac5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "2.3.5", + "version": "2.3.6", "description": "Cloud-based SQL data management tool", "main": "index.js", "bin": { diff --git a/utils/delete-file.js b/utils/delete-file.js index 3619252..08a0513 100644 --- a/utils/delete-file.js +++ b/utils/delete-file.js @@ -39,6 +39,12 @@ async function uploadImage({ key, url }) { const scheme = process.env.DSQL_HTTP_SCHEME; const localHost = process.env.DSQL_LOCAL_HOST; const localHostPort = process.env.DSQL_LOCAL_HOST_PORT; + const remoteHost = process.env.DSQL_API_REMOTE_HOST?.match(/.*\..*/) + ? process.env.DSQL_API_REMOTE_HOST + : undefined; + const remoteHostPort = process.env.DSQL_API_REMOTE_HOST_PORT?.match(/./) + ? process.env.DSQL_API_REMOTE_HOST_PORT + : undefined; try { /** @@ -59,8 +65,8 @@ async function uploadImage({ key, url }) { "Content-Length": Buffer.from(reqPayload).length, Authorization: key, }, - port: localHostPort || 443, - hostname: localHost || "datasquirel.com", + port: remoteHostPort || localHostPort || 443, + hostname: remoteHost || localHost || "datasquirel.com", path: `/api/query/delete-file`, }, diff --git a/utils/get-schema.js b/utils/get-schema.js index e1c099f..04ecbaf 100644 --- a/utils/get-schema.js +++ b/utils/get-schema.js @@ -31,6 +31,12 @@ async function getSchema({ key, database, field, table }) { const scheme = process.env.DSQL_HTTP_SCHEME; const localHost = process.env.DSQL_LOCAL_HOST; const localHostPort = process.env.DSQL_LOCAL_HOST_PORT; + const remoteHost = process.env.DSQL_API_REMOTE_HOST?.match(/.*\..*/) + ? process.env.DSQL_API_REMOTE_HOST + : undefined; + const remoteHostPort = process.env.DSQL_API_REMOTE_HOST_PORT?.match(/./) + ? process.env.DSQL_API_REMOTE_HOST_PORT + : undefined; /** * Make https request @@ -55,8 +61,8 @@ async function getSchema({ key, database, field, table }) { "Content-Type": "application/json", Authorization: key, }, - port: localHostPort || 443, - hostname: localHost || "datasquirel.com", + port: remoteHostPort || localHostPort || 443, + hostname: remoteHost || localHost || "datasquirel.com", path: "/api/query/get-schema" + (query?.match(/./) ? `?${query}` : ""), diff --git a/utils/get.js b/utils/get.js index 1c97289..b8b9e44 100644 --- a/utils/get.js +++ b/utils/get.js @@ -37,6 +37,12 @@ async function get({ key, db, query, queryValues, tableName }) { const scheme = process.env.DSQL_HTTP_SCHEME; const localHost = process.env.DSQL_LOCAL_HOST; const localHostPort = process.env.DSQL_LOCAL_HOST_PORT; + const remoteHost = process.env.DSQL_API_REMOTE_HOST?.match(/.*\..*/) + ? process.env.DSQL_API_REMOTE_HOST + : undefined; + const remoteHostPort = process.env.DSQL_API_REMOTE_HOST_PORT?.match(/./) + ? process.env.DSQL_API_REMOTE_HOST_PORT + : undefined; /** * Check for local DB settings @@ -107,8 +113,8 @@ async function get({ key, db, query, queryValues, tableName }) { "Content-Type": "application/json", Authorization: key, }, - port: localHostPort || 443, - hostname: localHost || "datasquirel.com", + port: remoteHostPort || localHostPort || 443, + hostname: remoteHost || localHost || "datasquirel.com", path: encodeURI(path), }; diff --git a/utils/post.js b/utils/post.js index 2021ce8..1807aef 100644 --- a/utils/post.js +++ b/utils/post.js @@ -34,6 +34,12 @@ async function post({ key, query, queryValues, database, tableName }) { const scheme = process.env.DSQL_HTTP_SCHEME; const localHost = process.env.DSQL_LOCAL_HOST; const localHostPort = process.env.DSQL_LOCAL_HOST_PORT; + const remoteHost = process.env.DSQL_API_REMOTE_HOST?.match(/.*\..*/) + ? process.env.DSQL_API_REMOTE_HOST + : undefined; + const remoteHostPort = process.env.DSQL_API_REMOTE_HOST_PORT?.match(/./) + ? process.env.DSQL_API_REMOTE_HOST_PORT + : undefined; /** * Check for local DB settings @@ -113,8 +119,8 @@ async function post({ key, query, queryValues, database, tableName }) { "Content-Length": Buffer.from(reqPayload).length, Authorization: key, }, - port: localHostPort || 443, - hostname: localHost || "datasquirel.com", + port: remoteHostPort || localHostPort || 443, + hostname: remoteHost || localHost || "datasquirel.com", path: `/api/query/post`, }, diff --git a/utils/upload-file.js b/utils/upload-file.js index b59c274..c823618 100644 --- a/utils/upload-file.js +++ b/utils/upload-file.js @@ -46,6 +46,12 @@ async function uploadImage({ key, payload }) { const scheme = process.env.DSQL_HTTP_SCHEME; const localHost = process.env.DSQL_LOCAL_HOST; const localHostPort = process.env.DSQL_LOCAL_HOST_PORT; + const remoteHost = process.env.DSQL_API_REMOTE_HOST?.match(/.*\..*/) + ? process.env.DSQL_API_REMOTE_HOST + : undefined; + const remoteHostPort = process.env.DSQL_API_REMOTE_HOST_PORT?.match(/./) + ? process.env.DSQL_API_REMOTE_HOST_PORT + : undefined; try { /** @@ -66,8 +72,8 @@ async function uploadImage({ key, payload }) { "Content-Length": Buffer.from(reqPayload).length, Authorization: key, }, - port: localHostPort || 443, - hostname: localHost || "datasquirel.com", + port: remoteHostPort || localHostPort || 443, + hostname: remoteHost || localHost || "datasquirel.com", path: `/api/query/add-file`, }, diff --git a/utils/upload-image.js b/utils/upload-image.js index 2feaa50..d7b3c08 100644 --- a/utils/upload-image.js +++ b/utils/upload-image.js @@ -48,6 +48,12 @@ async function uploadImage({ key, payload }) { const scheme = process.env.DSQL_HTTP_SCHEME; const localHost = process.env.DSQL_LOCAL_HOST; const localHostPort = process.env.DSQL_LOCAL_HOST_PORT; + const remoteHost = process.env.DSQL_API_REMOTE_HOST?.match(/.*\..*/) + ? process.env.DSQL_API_REMOTE_HOST + : undefined; + const remoteHostPort = process.env.DSQL_API_REMOTE_HOST_PORT?.match(/./) + ? process.env.DSQL_API_REMOTE_HOST_PORT + : undefined; try { /** @@ -68,8 +74,8 @@ async function uploadImage({ key, payload }) { "Content-Length": Buffer.from(reqPayload).length, Authorization: key, }, - port: localHostPort || 443, - hostname: localHost || "datasquirel.com", + port: remoteHostPort || localHostPort || 443, + hostname: remoteHost || localHost || "datasquirel.com", path: `/api/query/add-image`, },