minor revision

This commit is contained in:
Tben 2023-07-26 05:04:02 +01:00
parent 32a28c5b45
commit 4c1b856e55
2 changed files with 14 additions and 7 deletions

View File

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

View File

@ -26,17 +26,27 @@ const https = require("https");
* @param {Object} params - Single object passed * @param {Object} params - Single object passed
* @param {string} params.key - API Key * @param {string} params.key - API Key
* @param {string} params.db - Database Name * @param {string} params.db - Database Name
* @param {(string | Object)} params.query - SQL Query * @param {string} params.query - SQL Query
* @param {string[]} [params.queryValues] - An array of query values if using "?" placeholders
* *
* @returns { Promise<GetReturn> } - Return Object * @returns { Promise<GetReturn> } - Return Object
*/ */
async function get({ key, db, query }) { async function get({ key, db, query, queryValues }) {
/** /**
* Make https request * Make https request
* *
* @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) => {
let path = `/api/query/get?db=${db}&query=${query
.replace(/\n|\r|\n\r/g, "")
.replace(/ {2,}/g, " ")
.replace(/ /g, "+")}`;
if (queryValues) {
path += `&queryValues=${JSON.stringify(queryValues)}`;
}
https https
.request( .request(
{ {
@ -47,10 +57,7 @@ async function get({ key, db, query }) {
}, },
port: 443, port: 443,
hostname: "datasquirel.com", hostname: "datasquirel.com",
path: `/api/query/get?db=${db}&query=${query path: path,
.replace(/\n|\r|\n\r/g, "")
.replace(/ {2,}/g, " ")
.replace(/ /g, "+")}`,
}, },
/** /**