From cdcb3069c391b3df77f829ef41a7932a9211028a Mon Sep 17 00:00:00 2001 From: Tben Date: Fri, 7 Jul 2023 20:13:13 +0100 Subject: [PATCH] updates --- engine/db/{add.js => addDb.js} | 13 +++++++++++-- engine/db/deleteDb.js | 10 ++++++++-- engine/db/query.js | 10 ++++++++-- engine/db/updateDb.js | 10 ++++++++-- engine/index.js | 4 ++-- package.json | 2 +- users/add-user.js | 6 ++++-- users/get-user.js | 7 ++++--- users/login-user.js | 6 ++++-- users/logout-user.js | 6 ++++-- users/reauth-user.js | 6 ++++-- users/social/google-auth.js | 6 ++++-- users/update-user.js | 6 ++++-- users/user-auth.js | 6 ++++-- utils/get.js | 6 ++++-- utils/post.js | 6 ++++-- utils/upload-image.js | 6 ++++-- 17 files changed, 82 insertions(+), 34 deletions(-) rename engine/db/{add.js => addDb.js} (91%) diff --git a/engine/db/add.js b/engine/db/addDb.js similarity index 91% rename from engine/db/add.js rename to engine/db/addDb.js index c523053..7e762d0 100644 --- a/engine/db/add.js +++ b/engine/db/addDb.js @@ -30,7 +30,7 @@ const updateDb = require("./updateDb"); * * @returns {Promise} */ -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 */ @@ -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 queryValuesArray = insertValuesArray; + console.log("DSQL: Query =>", query); + console.log("DSQL: Query Values =>", queryValuesArray); + const newInsert = await handler({ queryString: query, database: dbFullName, @@ -153,4 +156,10 @@ module.exports = async function add({ dbFullName, tableName, data, tableSchema, * Return statement */ return newInsert; -}; +} + +//////////////////////////////////////// +//////////////////////////////////////// +//////////////////////////////////////// + +module.exports = addDb; diff --git a/engine/db/deleteDb.js b/engine/db/deleteDb.js index 7c7cf14..73042f5 100644 --- a/engine/db/deleteDb.js +++ b/engine/db/deleteDb.js @@ -24,7 +24,7 @@ const handler = require("../utils/handler"); * * @returns {Promise} */ -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 { /** * Check if data is valid @@ -71,4 +71,10 @@ module.exports = async function deleteDb({ dbFullName, tableName, identifierColu return null; } -}; +} + +//////////////////////////////////////// +//////////////////////////////////////// +//////////////////////////////////////// + +module.exports = deleteDb; diff --git a/engine/db/query.js b/engine/db/query.js index 3940b2f..e1f12cd 100644 --- a/engine/db/query.js +++ b/engine/db/query.js @@ -19,7 +19,7 @@ const handler = require("../utils/handler"); * * @returns {Promise} */ -module.exports = async function query({ dbFullName, dbHost, dbPassword, dbUsername, query }) { +async function query({ dbFullName, dbHost, dbPassword, dbUsername, query }) { /** * 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); return null; } -}; +} + +//////////////////////////////////////// +//////////////////////////////////////// +//////////////////////////////////////// + +module.exports = query; diff --git a/engine/db/updateDb.js b/engine/db/updateDb.js index 7c41a15..a8c6233 100644 --- a/engine/db/updateDb.js +++ b/engine/db/updateDb.js @@ -25,7 +25,7 @@ const handler = require("../utils/handler"); * * @returns {Promise} */ -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 */ @@ -89,4 +89,10 @@ module.exports = async function updateDb({ dbFullName, tableName, data, tableSch * Return statement */ return updatedEntry; -}; +} + +//////////////////////////////////////// +//////////////////////////////////////// +//////////////////////////////////////// + +module.exports = updateDb; diff --git a/engine/index.js b/engine/index.js index a54db7e..3d6db65 100644 --- a/engine/index.js +++ b/engine/index.js @@ -2,7 +2,7 @@ * Imports * =================================== */ -const add = require("./db/add"); +const addDb = require("./db/addDb"); const query = require("./db/query"); const update = require("./db/updateDb"); const deleteDb = require("./db/deleteDb"); @@ -16,7 +16,7 @@ const deleteDb = require("./db/deleteDb"); * =================================== */ const db = { - add: add, + add: addDb, update: update, delete: deleteDb, query: query, diff --git a/package.json b/package.json index a33aec1..8d96da5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "1.1.70", + "version": "1.1.71", "description": "Cloud-based SQL data management tool", "main": "index.js", "scripts": { diff --git a/users/add-user.js b/users/add-user.js index a6c2f65..c8d2b5d 100644 --- a/users/add-user.js +++ b/users/add-user.js @@ -38,7 +38,7 @@ const https = require("https"); * * @returns { Promise } */ -module.exports = async function ({ key, payload, database }) { +async function addUser({ key, payload, database }) { /** * Make https request * @@ -93,8 +93,10 @@ module.exports = async function ({ key, payload, database }) { /** ********************************************** */ return httpResponse; -}; +} /** ********************************************** */ /** ********************************************** */ /** ********************************************** */ + +module.exports = addUser; diff --git a/users/get-user.js b/users/get-user.js index db8f323..d822cef 100644 --- a/users/get-user.js +++ b/users/get-user.js @@ -4,7 +4,6 @@ * ============================================================================== */ const https = require("https"); -const encrypt = require("../functions/encrypt"); /** ****************************************************************************** */ /** ****************************************************************************** */ @@ -44,7 +43,7 @@ const encrypt = require("../functions/encrypt"); * * @returns { Promise} */ -module.exports = async function ({ key, userId, database, fields }) { +async function getUser({ key, userId, database, fields }) { /** * Make https request * @@ -105,8 +104,10 @@ module.exports = async function ({ key, userId, database, fields }) { /** ********************************************** */ return httpResponse; -}; +} /** ********************************************** */ /** ********************************************** */ /** ********************************************** */ + +module.exports = getUser; diff --git a/users/login-user.js b/users/login-user.js index 6ef3294..b77c4bc 100644 --- a/users/login-user.js +++ b/users/login-user.js @@ -55,7 +55,7 @@ const encrypt = require("../functions/encrypt"); * * @returns { Promise} */ -module.exports = async function ({ key, payload, database, response, encryptionKey, encryptionSalt }) { +async function loginUser({ key, payload, database, response, encryptionKey, encryptionSalt }) { /** * Check Encryption Keys * @@ -170,8 +170,10 @@ module.exports = async function ({ key, payload, database, response, encryptionK /** ********************************************** */ return httpResponse; -}; +} /** ********************************************** */ /** ********************************************** */ /** ********************************************** */ + +module.exports = loginUser; diff --git a/users/logout-user.js b/users/logout-user.js index f8a9ec2..1a26c34 100644 --- a/users/logout-user.js +++ b/users/logout-user.js @@ -12,7 +12,7 @@ const parseCookies = require("../utils/functions/parseCookies"); * * @returns {{success: boolean, payload: string}} */ -module.exports = function ({ request, response, database }) { +function logoutUser({ request, response, database }) { /** * Check Encryption Keys * @@ -62,8 +62,10 @@ module.exports = function ({ request, response, database }) { /** ********************************************** */ /** ********************************************** */ /** ********************************************** */ -}; +} /** ********************************************** */ /** ********************************************** */ /** ********************************************** */ + +module.exports = logoutUser; diff --git a/users/reauth-user.js b/users/reauth-user.js index c7c6ba6..d7242d5 100644 --- a/users/reauth-user.js +++ b/users/reauth-user.js @@ -57,7 +57,7 @@ const userAuth = require("./user-auth"); * * @returns { Promise } */ -module.exports = async function ({ key, database, response, request, level, encryptionKey, encryptionSalt }) { +async function reauthUser({ key, database, response, request, level, encryptionKey, encryptionSalt }) { /** * Check Encryption Keys * @@ -158,8 +158,10 @@ module.exports = async function ({ key, database, response, request, level, encr /** ********************************************** */ return httpResponse; -}; +} /** ********************************************** */ /** ********************************************** */ /** ********************************************** */ + +module.exports = reauthUser; diff --git a/users/social/google-auth.js b/users/social/google-auth.js index bb11c56..a6c8f85 100644 --- a/users/social/google-auth.js +++ b/users/social/google-auth.js @@ -37,7 +37,7 @@ const encrypt = require("../../functions/encrypt"); * * @returns { Promise } */ -module.exports = async function ({ key, token, database, clientId, response, encryptionKey, encryptionSalt }) { +async function googleAuth({ key, token, database, clientId, response, encryptionKey, encryptionSalt }) { /** * Check inputs * @@ -183,8 +183,10 @@ module.exports = async function ({ key, token, database, clientId, response, enc //////////////////////////////////////// return httpResponse; -}; +} //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// + +module.exports = googleAuth; diff --git a/users/update-user.js b/users/update-user.js index 6830900..1727cf9 100644 --- a/users/update-user.js +++ b/users/update-user.js @@ -31,7 +31,7 @@ const https = require("https"); * * @returns { Promise} */ -module.exports = async function ({ key, payload, database }) { +async function updateUser({ key, payload, database }) { /** * Make https request * @@ -86,8 +86,10 @@ module.exports = async function ({ key, payload, database }) { /** ********************************************** */ return httpResponse; -}; +} /** ********************************************** */ /** ********************************************** */ /** ********************************************** */ + +module.exports = updateUser; diff --git a/users/user-auth.js b/users/user-auth.js index 0151106..2416492 100644 --- a/users/user-auth.js +++ b/users/user-auth.js @@ -50,7 +50,7 @@ const parseCookies = require("../utils/functions/parseCookies"); * * @returns { FunctionReturn } */ -module.exports = function ({ request, encryptionKey, encryptionSalt, level, database }) { +function userAuth({ request, encryptionKey, encryptionSalt, level, database }) { try { /** * Grab the payload @@ -146,8 +146,10 @@ module.exports = function ({ request, encryptionKey, encryptionSalt, level, data msg: error.message, }; } -}; +} /** ********************************************** */ /** ********************************************** */ /** ********************************************** */ + +module.exports = userAuth; diff --git a/utils/get.js b/utils/get.js index 671f554..efc82f2 100644 --- a/utils/get.js +++ b/utils/get.js @@ -31,7 +31,7 @@ const https = require("https"); * * @returns { Promise } - Return Object */ -module.exports = async function ({ key, db, query }) { +async function get({ key, db, query }) { /** * Make https request * @@ -83,8 +83,10 @@ module.exports = async function ({ key, db, query }) { /** ********************************************** */ return httpResponse; -}; +} /** ********************************************** */ /** ********************************************** */ /** ********************************************** */ + +module.exports = get; diff --git a/utils/post.js b/utils/post.js index 5ee0550..a1d1b2a 100644 --- a/utils/post.js +++ b/utils/post.js @@ -42,7 +42,7 @@ const https = require("https"); * * @returns { Promise } - Return Object */ -module.exports = async function ({ key, query, database }) { +async function post({ key, query, database }) { /** * Make https request * @@ -133,8 +133,10 @@ module.exports = async function ({ key, query, database }) { /** ********************************************** */ return httpResponse; -}; +} /** ********************************************** */ /** ********************************************** */ /** ********************************************** */ + +module.exports = post; diff --git a/utils/upload-image.js b/utils/upload-image.js index 53160ba..75ca94b 100644 --- a/utils/upload-image.js +++ b/utils/upload-image.js @@ -39,7 +39,7 @@ const https = require("https"); * * @returns { Promise } - Return Object */ -module.exports = async function ({ key, payload }) { +async function uploadImage({ key, payload }) { /** * Make https request * @@ -92,8 +92,10 @@ module.exports = async function ({ key, payload }) { /** ********************************************** */ return httpResponse; -}; +} /** ********************************************** */ /** ********************************************** */ /** ********************************************** */ + +module.exports = uploadImage;