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",
"version": "1.0.5",
"version": "1.0.6",
"description": "Cloud-based SQL data management tool",
"main": "index.js",
"scripts": {

View File

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

View File

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

View File

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

View File

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