This commit is contained in:
Tben 2023-05-06 13:18:44 +01:00
parent 1eb11ede15
commit 224dbf4175
5 changed files with 142 additions and 135 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "datasquirel", "name": "datasquirel",
"version": "1.0.5", "version": "1.0.6",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -35,47 +35,47 @@ module.exports = async function ({ key, payload, database }) {
* @description make a request to datasquirel.com * @description make a request to datasquirel.com
*/ */
const httpResponse = await new Promise((resolve, reject) => { const httpResponse = await new Promise((resolve, reject) => {
https const reqPayload = JSON.stringify({
.request( payload,
{ database,
method: "POST", });
headers: {
"Content-Type": "application/json", const httpsRequest = https.request(
Authorization: key, {
}, method: "POST",
port: 443, headers: {
hostname: "datasquirel.com", "Content-Type": "application/json",
path: `/api/user/add-user`, "Content-Length": reqPayload.length,
Authorization: key,
}, },
port: 443,
hostname: "datasquirel.com",
path: `/api/user/add-user`,
},
/** /**
* Callback Function * Callback Function
* *
* @description https request callback * @description https request callback
*/ */
(response) => { (response) => {
var str = ""; var str = "";
response.on("data", function (chunk) { response.on("data", function (chunk) {
str += chunk; str += chunk;
}); });
response.on("end", function () { response.on("end", function () {
resolve(JSON.parse(str)); resolve(JSON.parse(str));
}); });
response.on("error", (err) => { response.on("error", (err) => {
reject(err); reject(err);
}); });
} }
) );
.write( httpsRequest.write(reqPayload);
JSON.stringify({ httpsRequest.end();
payload,
database,
})
)
.end();
}); });
/** ********************************************** */ /** ********************************************** */

View File

@ -72,47 +72,48 @@ module.exports = async function ({ key, payload, database, response, encryptionK
* @description make a request to datasquirel.com * @description make a request to datasquirel.com
*/ */
const httpResponse = await new Promise((resolve, reject) => { const httpResponse = await new Promise((resolve, reject) => {
https const reqPayload = JSON.stringify({
.request( payload,
{ database,
method: "POST", });
headers: {
"Content-Type": "application/json", const httpsRequest = https.request(
Authorization: key, {
}, method: "POST",
port: 443, headers: {
hostname: "datasquirel.com", "Content-Type": "application/json",
path: `/api/user/login-user`, "Content-Length": reqPayload.length,
Authorization: key,
}, },
port: 443,
hostname: "datasquirel.com",
path: `/api/user/login-user`,
},
/** /**
* Callback Function * Callback Function
* *
* @description https request callback * @description https request callback
*/ */
(response) => { (response) => {
var str = ""; var str = "";
response.on("data", function (chunk) { response.on("data", function (chunk) {
str += chunk; str += chunk;
}); });
response.on("end", function () { response.on("end", function () {
resolve(JSON.parse(str)); resolve(JSON.parse(str));
}); });
response.on("error", (err) => { response.on("error", (err) => {
reject(err); reject(err);
}); });
} }
) );
.write(
JSON.stringify({ httpsRequest.write(reqPayload);
payload, httpsRequest.end();
database,
})
)
.end();
}); });
/** ********************************************** */ /** ********************************************** */

View File

@ -34,42 +34,45 @@ module.exports = async function ({ key, payload }) {
* @description make a request to datasquirel.com * @description make a request to datasquirel.com
*/ */
const httpResponse = await new Promise((resolve, reject) => { const httpResponse = await new Promise((resolve, reject) => {
https const reqPayload = JSON.stringify(payload);
.request(
{ const httpsRequest = https.request(
method: "POST", {
headers: { method: "POST",
"Content-Type": "application/json", headers: {
Authorization: key, "Content-Type": "application/json",
}, "Content-Length": reqPayload.length,
port: 443, Authorization: key,
hostname: "datasquirel.com",
path: `/api/query/post`,
}, },
port: 443,
hostname: "datasquirel.com",
path: `/api/query/post`,
},
/** /**
* Callback Function * Callback Function
* *
* @description https request callback * @description https request callback
*/ */
(response) => { (response) => {
var str = ""; var str = "";
response.on("data", function (chunk) { response.on("data", function (chunk) {
str += chunk; str += chunk;
}); });
response.on("end", function () { response.on("end", function () {
resolve(JSON.parse(str)); resolve(JSON.parse(str));
}); });
response.on("error", (err) => { response.on("error", (err) => {
reject(err); reject(err);
}); });
} }
) );
.write(JSON.stringify(payload))
.end(); httpsRequest.write(reqPayload);
httpsRequest.end();
}); });
/** ********************************************** */ /** ********************************************** */

View File

@ -31,42 +31,45 @@ module.exports = async function ({ key, payload }) {
* @description make a request to datasquirel.com * @description make a request to datasquirel.com
*/ */
const httpResponse = await new Promise((resolve, reject) => { const httpResponse = await new Promise((resolve, reject) => {
https const reqPayload = JSON.stringify(payload);
.request(
{ const httpsRequest = https.request(
method: "POST", {
headers: { method: "POST",
"Content-Type": "application/json", headers: {
Authorization: key, "Content-Type": "application/json",
}, "Content-Length": reqPayload.length,
port: 443, Authorization: key,
hostname: "datasquirel.com",
path: `/api/query/post`,
}, },
port: 443,
hostname: "datasquirel.com",
path: `/api/query/post`,
},
/** /**
* Callback Function * Callback Function
* *
* @description https request callback * @description https request callback
*/ */
(response) => { (response) => {
var str = ""; var str = "";
response.on("data", function (chunk) { response.on("data", function (chunk) {
str += chunk; str += chunk;
}); });
response.on("end", function () { response.on("end", function () {
resolve(JSON.parse(str)); resolve(JSON.parse(str));
}); });
response.on("error", (err) => { response.on("error", (err) => {
reject(err); reject(err);
}); });
} }
) );
.write(JSON.stringify(payload))
.end(); httpsRequest.write(reqPayload);
httpsRequest.end();
}); });
/** ********************************************** */ /** ********************************************** */