This commit is contained in:
Tben 2023-07-07 20:13:13 +01:00
parent b43eb1f990
commit cdcb3069c3
17 changed files with 82 additions and 34 deletions

View File

@ -30,7 +30,7 @@ const updateDb = require("./updateDb");
* *
* @returns {Promise<object|null>} * @returns {Promise<object|null>}
*/ */
module.exports = async function add({ dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, dbHost, dbPassword, dbUsername, encryptionKey, encryptionSalt }) { async function addDb({ dbFullName, tableName, data, tableSchema, duplicateColumnName, duplicateColumnValue, update, dbHost, dbPassword, dbUsername, encryptionKey, encryptionSalt }) {
/** /**
* Initialize variables * Initialize variables
*/ */
@ -133,6 +133,9 @@ module.exports = async function add({ dbFullName, tableName, data, tableSchema,
const query = `INSERT INTO \`${tableName}\` (${insertKeysArray.join(",")}) VALUES (${insertValuesArray.map(() => "?").join(",")})`; const query = `INSERT INTO \`${tableName}\` (${insertKeysArray.join(",")}) VALUES (${insertValuesArray.map(() => "?").join(",")})`;
const queryValuesArray = insertValuesArray; const queryValuesArray = insertValuesArray;
console.log("DSQL: Query =>", query);
console.log("DSQL: Query Values =>", queryValuesArray);
const newInsert = await handler({ const newInsert = await handler({
queryString: query, queryString: query,
database: dbFullName, database: dbFullName,
@ -153,4 +156,10 @@ module.exports = async function add({ dbFullName, tableName, data, tableSchema,
* Return statement * Return statement
*/ */
return newInsert; return newInsert;
}; }
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
module.exports = addDb;

View File

@ -24,7 +24,7 @@ const handler = require("../utils/handler");
* *
* @returns {Promise<object|null>} * @returns {Promise<object|null>}
*/ */
module.exports = async function deleteDb({ dbFullName, tableName, identifierColumnName, identifierValue, dbHost, dbPassword, dbUsername, encryptionKey, encryptionSalt }) { async function deleteDb({ dbFullName, tableName, identifierColumnName, identifierValue, dbHost, dbPassword, dbUsername, encryptionKey, encryptionSalt }) {
try { try {
/** /**
* Check if data is valid * Check if data is valid
@ -71,4 +71,10 @@ module.exports = async function deleteDb({ dbFullName, tableName, identifierColu
return null; return null;
} }
}; }
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
module.exports = deleteDb;

View File

@ -19,7 +19,7 @@ const handler = require("../utils/handler");
* *
* @returns {Promise<object|null>} * @returns {Promise<object|null>}
*/ */
module.exports = async function query({ dbFullName, dbHost, dbPassword, dbUsername, query }) { async function query({ dbFullName, dbHost, dbPassword, dbUsername, query }) {
/** /**
* Initialize variables * Initialize variables
*/ */
@ -74,4 +74,10 @@ module.exports = async function query({ dbFullName, dbHost, dbPassword, dbUserna
console.log("\x1b[31mDSQL RAW Database Handler No results returned\x1b[0m =>", results); console.log("\x1b[31mDSQL RAW Database Handler No results returned\x1b[0m =>", results);
return null; return null;
} }
}; }
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
module.exports = query;

View File

@ -25,7 +25,7 @@ const handler = require("../utils/handler");
* *
* @returns {Promise<object|null>} * @returns {Promise<object|null>}
*/ */
module.exports = async function updateDb({ dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, dbHost, dbPassword, dbUsername, encryptionKey, encryptionSalt }) { async function updateDb({ dbFullName, tableName, data, tableSchema, identifierColumnName, identifierValue, dbHost, dbPassword, dbUsername, encryptionKey, encryptionSalt }) {
/** /**
* Check if data is valid * Check if data is valid
*/ */
@ -89,4 +89,10 @@ module.exports = async function updateDb({ dbFullName, tableName, data, tableSch
* Return statement * Return statement
*/ */
return updatedEntry; return updatedEntry;
}; }
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
module.exports = updateDb;

View File

@ -2,7 +2,7 @@
* Imports * Imports
* =================================== * ===================================
*/ */
const add = require("./db/add"); const addDb = require("./db/addDb");
const query = require("./db/query"); const query = require("./db/query");
const update = require("./db/updateDb"); const update = require("./db/updateDb");
const deleteDb = require("./db/deleteDb"); const deleteDb = require("./db/deleteDb");
@ -16,7 +16,7 @@ const deleteDb = require("./db/deleteDb");
* =================================== * ===================================
*/ */
const db = { const db = {
add: add, add: addDb,
update: update, update: update,
delete: deleteDb, delete: deleteDb,
query: query, query: query,

View File

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

View File

@ -38,7 +38,7 @@ const https = require("https");
* *
* @returns { Promise<FunctionReturn> } * @returns { Promise<FunctionReturn> }
*/ */
module.exports = async function ({ key, payload, database }) { async function addUser({ key, payload, database }) {
/** /**
* Make https request * Make https request
* *
@ -93,8 +93,10 @@ module.exports = async function ({ key, payload, database }) {
/** ********************************************** */ /** ********************************************** */
return httpResponse; return httpResponse;
}; }
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
module.exports = addUser;

View File

@ -4,7 +4,6 @@
* ============================================================================== * ==============================================================================
*/ */
const https = require("https"); const https = require("https");
const encrypt = require("../functions/encrypt");
/** ****************************************************************************** */ /** ****************************************************************************** */
/** ****************************************************************************** */ /** ****************************************************************************** */
@ -44,7 +43,7 @@ const encrypt = require("../functions/encrypt");
* *
* @returns { Promise<FunctionReturn>} * @returns { Promise<FunctionReturn>}
*/ */
module.exports = async function ({ key, userId, database, fields }) { async function getUser({ key, userId, database, fields }) {
/** /**
* Make https request * Make https request
* *
@ -105,8 +104,10 @@ module.exports = async function ({ key, userId, database, fields }) {
/** ********************************************** */ /** ********************************************** */
return httpResponse; return httpResponse;
}; }
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
module.exports = getUser;

View File

@ -55,7 +55,7 @@ const encrypt = require("../functions/encrypt");
* *
* @returns { Promise<FunctionReturn>} * @returns { Promise<FunctionReturn>}
*/ */
module.exports = async function ({ key, payload, database, response, encryptionKey, encryptionSalt }) { async function loginUser({ key, payload, database, response, encryptionKey, encryptionSalt }) {
/** /**
* Check Encryption Keys * Check Encryption Keys
* *
@ -170,8 +170,10 @@ module.exports = async function ({ key, payload, database, response, encryptionK
/** ********************************************** */ /** ********************************************** */
return httpResponse; return httpResponse;
}; }
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
module.exports = loginUser;

View File

@ -12,7 +12,7 @@ const parseCookies = require("../utils/functions/parseCookies");
* *
* @returns {{success: boolean, payload: string}} * @returns {{success: boolean, payload: string}}
*/ */
module.exports = function ({ request, response, database }) { function logoutUser({ request, response, database }) {
/** /**
* Check Encryption Keys * Check Encryption Keys
* *
@ -62,8 +62,10 @@ module.exports = function ({ request, response, database }) {
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
}; }
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
module.exports = logoutUser;

View File

@ -57,7 +57,7 @@ const userAuth = require("./user-auth");
* *
* @returns { Promise<FunctionReturn> } * @returns { Promise<FunctionReturn> }
*/ */
module.exports = async function ({ key, database, response, request, level, encryptionKey, encryptionSalt }) { async function reauthUser({ key, database, response, request, level, encryptionKey, encryptionSalt }) {
/** /**
* Check Encryption Keys * Check Encryption Keys
* *
@ -158,8 +158,10 @@ module.exports = async function ({ key, database, response, request, level, encr
/** ********************************************** */ /** ********************************************** */
return httpResponse; return httpResponse;
}; }
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
module.exports = reauthUser;

View File

@ -37,7 +37,7 @@ const encrypt = require("../../functions/encrypt");
* *
* @returns { Promise<FunctionReturn> } * @returns { Promise<FunctionReturn> }
*/ */
module.exports = async function ({ key, token, database, clientId, response, encryptionKey, encryptionSalt }) { async function googleAuth({ key, token, database, clientId, response, encryptionKey, encryptionSalt }) {
/** /**
* Check inputs * Check inputs
* *
@ -183,8 +183,10 @@ module.exports = async function ({ key, token, database, clientId, response, enc
//////////////////////////////////////// ////////////////////////////////////////
return httpResponse; return httpResponse;
}; }
//////////////////////////////////////// ////////////////////////////////////////
//////////////////////////////////////// ////////////////////////////////////////
//////////////////////////////////////// ////////////////////////////////////////
module.exports = googleAuth;

View File

@ -31,7 +31,7 @@ const https = require("https");
* *
* @returns { Promise<FunctionReturn>} * @returns { Promise<FunctionReturn>}
*/ */
module.exports = async function ({ key, payload, database }) { async function updateUser({ key, payload, database }) {
/** /**
* Make https request * Make https request
* *
@ -86,8 +86,10 @@ module.exports = async function ({ key, payload, database }) {
/** ********************************************** */ /** ********************************************** */
return httpResponse; return httpResponse;
}; }
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
module.exports = updateUser;

View File

@ -50,7 +50,7 @@ const parseCookies = require("../utils/functions/parseCookies");
* *
* @returns { FunctionReturn } * @returns { FunctionReturn }
*/ */
module.exports = function ({ request, encryptionKey, encryptionSalt, level, database }) { function userAuth({ request, encryptionKey, encryptionSalt, level, database }) {
try { try {
/** /**
* Grab the payload * Grab the payload
@ -146,8 +146,10 @@ module.exports = function ({ request, encryptionKey, encryptionSalt, level, data
msg: error.message, msg: error.message,
}; };
} }
}; }
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
module.exports = userAuth;

View File

@ -31,7 +31,7 @@ const https = require("https");
* *
* @returns { Promise<GetReturn> } - Return Object * @returns { Promise<GetReturn> } - Return Object
*/ */
module.exports = async function ({ key, db, query }) { async function get({ key, db, query }) {
/** /**
* Make https request * Make https request
* *
@ -83,8 +83,10 @@ module.exports = async function ({ key, db, query }) {
/** ********************************************** */ /** ********************************************** */
return httpResponse; return httpResponse;
}; }
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
module.exports = get;

View File

@ -42,7 +42,7 @@ const https = require("https");
* *
* @returns { Promise<PostReturn> } - Return Object * @returns { Promise<PostReturn> } - Return Object
*/ */
module.exports = async function ({ key, query, database }) { async function post({ key, query, database }) {
/** /**
* Make https request * Make https request
* *
@ -133,8 +133,10 @@ module.exports = async function ({ key, query, database }) {
/** ********************************************** */ /** ********************************************** */
return httpResponse; return httpResponse;
}; }
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
module.exports = post;

View File

@ -39,7 +39,7 @@ const https = require("https");
* *
* @returns { Promise<FunctionReturn> } - Return Object * @returns { Promise<FunctionReturn> } - Return Object
*/ */
module.exports = async function ({ key, payload }) { async function uploadImage({ key, payload }) {
/** /**
* Make https request * Make https request
* *
@ -92,8 +92,10 @@ module.exports = async function ({ key, payload }) {
/** ********************************************** */ /** ********************************************** */
return httpResponse; return httpResponse;
}; }
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
/** ********************************************** */ /** ********************************************** */
module.exports = uploadImage;