Add Remote API
This commit is contained in:
parent
190598aa3f
commit
6c78cae127
@ -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;
|
||||
|
||||
/** ********************************************** */
|
||||
/** ********************************************** */
|
||||
/** ********************************************** */
|
||||
|
@ -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": {
|
||||
|
@ -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`,
|
||||
},
|
||||
|
||||
|
@ -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}` : ""),
|
||||
|
10
utils/get.js
10
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),
|
||||
};
|
||||
|
||||
|
@ -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`,
|
||||
},
|
||||
|
||||
|
@ -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`,
|
||||
},
|
||||
|
||||
|
@ -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`,
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user