This commit is contained in:
Benjamin Toby
2025-02-19 20:01:50 +01:00
parent c08db13f3d
commit e9bb9fb07f
113 changed files with 253 additions and 63 deletions
+2
View File
@@ -26,6 +26,7 @@ const grab_dsql_connection_1 = __importDefault(require("../utils/grab-dsql-conne
* @returns {Promise<object|null>}
*/
(() => __awaiter(void 0, void 0, void 0, function* () {
var _a;
const CONNECTION = (0, grab_dsql_connection_1.default)();
try {
const result = yield CONNECTION.query("SELECT id,first_name,last_name FROM users LIMIT 3");
@@ -33,6 +34,7 @@ const grab_dsql_connection_1 = __importDefault(require("../utils/grab-dsql-conne
}
catch (error) {
console.log("Connection query ERROR =>", error.message);
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Error Checking DB`, error);
}
finally {
CONNECTION === null || CONNECTION === void 0 ? void 0 : CONNECTION.end();
@@ -22,6 +22,7 @@ const addDbEntry_1 = __importDefault(require("../../functions/backend/db/addDbEn
*/
function checkDbRecordCreateDbSchema(_a) {
return __awaiter(this, arguments, void 0, function* ({ userId, dbSchema, }) {
var _b;
try {
const { dbFullName, dbName, dbSlug, dbDescription, dbImage, childDatabase, childDatabaseDbFullName, } = dbSchema;
let recordedDbEntryArray = userId
@@ -58,6 +59,7 @@ function checkDbRecordCreateDbSchema(_a) {
return recordedDbEntry;
}
catch (error) {
(_b = global.ERROR_CALLBACK) === null || _b === void 0 ? void 0 : _b.call(global, `Error Checking DB Record on Creating Schema`, error);
return undefined;
}
});
@@ -23,6 +23,7 @@ const addDbEntry_1 = __importDefault(require("../../functions/backend/db/addDbEn
*/
function checkTableRecordCreateDbSchema(_a) {
return __awaiter(this, arguments, void 0, function* ({ userId, tableSchema, dbSchema, dbRecord, dbFullName, }) {
var _b;
if (!tableSchema)
return undefined;
try {
@@ -86,6 +87,7 @@ function checkTableRecordCreateDbSchema(_a) {
return recordedTableEntry;
}
catch (error) {
(_b = global.ERROR_CALLBACK) === null || _b === void 0 ? void 0 : _b.call(global, `Error Checking Table Record on Creating Schema`, error);
return undefined;
}
});
@@ -22,6 +22,7 @@ const varDatabaseDbHandler_1 = __importDefault(require("../utils/varDatabaseDbHa
*/
function handleIndexescreateDbFromSchema(_a) {
return __awaiter(this, arguments, void 0, function* ({ dbFullName, tableName, indexes, }) {
var _b;
for (let g = 0; g < indexes.length; g++) {
const { indexType, indexName, indexTableFields, alias } = indexes[g];
if (!(alias === null || alias === void 0 ? void 0 : alias.match(/./)))
@@ -42,6 +43,7 @@ function handleIndexescreateDbFromSchema(_a) {
throw new Error("This Index Does not Exist");
}
catch (error) {
(_b = global.ERROR_CALLBACK) === null || _b === void 0 ? void 0 : _b.call(global, `Error Handling Indexes on Creating Schema`, error);
/**
* @description Create new index if determined that it
* doesn't exist in MYSQL db
@@ -27,7 +27,7 @@ const defaultMariadbUserHost = process.env.DSQL_DB_HOST || "127.0.0.1";
*/
function refreshUsersAndGrants(_a) {
return __awaiter(this, arguments, void 0, function* ({ userId, mariadbUserHost, mariadbUsername, sqlUserID, }) {
var _b, _c, _d, _e;
var _b, _c, _d, _e, _f;
const mariadbUsers = (yield (0, dbHandler_1.default)({
query: `SELECT * FROM mariadb_users`,
}));
@@ -190,7 +190,7 @@ function refreshUsersAndGrants(_a) {
}
}
catch (error) {
console.log(`Error in adding SQL user =>`, error.message);
(_f = global.ERROR_CALLBACK) === null || _f === void 0 ? void 0 : _f.call(global, `Error Refreshing MariaDB Users and Grants`, error);
}
}
});
@@ -22,6 +22,7 @@ const encrypt_1 = __importDefault(require("../../functions/dsql/encrypt"));
*/
function resetSQLCredentialsPasswords() {
return __awaiter(this, void 0, void 0, function* () {
var _a;
const users = (yield (0, dbHandler_1.default)({
query: `SELECT * FROM users`,
}));
@@ -61,7 +62,7 @@ function resetSQLCredentialsPasswords() {
}
}
catch (error) {
console.log(`Error Updating User ${user.id} Password =>`, error.message);
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Error Resetting MariaDB User Password`, error);
}
}
process.exit();
@@ -28,6 +28,7 @@ const tmpDir = process.argv[process.argv.length - 1];
*/
function createUser() {
return __awaiter(this, void 0, void 0, function* () {
var _a;
/**
* Validate Form
*
@@ -126,7 +127,7 @@ function createUser() {
return true;
}
catch (error) {
console.log(`Error in creating user => ${error.message}`);
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Error Creating User`, error);
return false;
}
});
@@ -24,6 +24,7 @@ const tmpDir = process.argv[process.argv.length - 1];
*/
function createUser() {
return __awaiter(this, void 0, void 0, function* () {
var _a;
/**
* Validate Form
*
@@ -65,7 +66,7 @@ function createUser() {
return true;
}
catch (error) {
console.log(`Error in creating user => ${error.message}`);
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Error Updating User`, error);
return false;
}
});
+2
View File
@@ -25,6 +25,7 @@ const encrypt_1 = __importDefault(require("../functions/dsql/encrypt"));
*/
function resetSQLCredentials() {
return __awaiter(this, void 0, void 0, function* () {
var _a;
const users = (yield (0, dbHandler_1.default)({
query: `SELECT * FROM users`,
}));
@@ -63,6 +64,7 @@ function resetSQLCredentials() {
console.log(`User ${user.id}: ${user.first_name} ${user.last_name} SQL credentials successfully added.`);
}
catch (error) {
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Error Resetting SQL credentials`, error);
console.log(`Error in adding SQL user =>`, error.message);
}
}
+2 -1
View File
@@ -22,6 +22,7 @@ const encrypt_1 = __importDefault(require("../functions/dsql/encrypt"));
*/
function resetSQLCredentialsPasswords() {
return __awaiter(this, void 0, void 0, function* () {
var _a;
const users = (yield (0, dbHandler_1.default)({
query: `SELECT * FROM users`,
}));
@@ -51,7 +52,7 @@ function resetSQLCredentialsPasswords() {
console.log(`User ${user.id}: ${user.first_name} ${user.last_name} Password Updated successfully added.`);
}
catch (error) {
console.log(`Error Updating User ${user.id} Password =>`, error.message);
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Error Updating MariaDB User`, error);
}
}
process.exit();
+2 -1
View File
@@ -28,6 +28,7 @@ const encrypt_1 = __importDefault(require("../functions/dsql/encrypt"));
*/
function setSQLCredentials() {
return __awaiter(this, void 0, void 0, function* () {
var _a;
const users = (yield (0, dbHandler_1.default)({
query: `SELECT * FROM users`,
}));
@@ -61,7 +62,7 @@ function setSQLCredentials() {
console.log(`User ${user.id}: ${user.first_name} ${user.last_name} SQL credentials successfully added.`);
}
catch (error) {
console.log(`Error in adding SQL user =>`, error.message);
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Error Setting SQL credentials`, error);
}
}
});
+2 -1
View File
@@ -26,6 +26,7 @@ const grab_dsql_connection_1 = __importDefault(require("../utils/grab-dsql-conne
* @returns {Promise<object|null>}
*/
(() => __awaiter(void 0, void 0, void 0, function* () {
var _a;
const CONNECTION = (0, grab_dsql_connection_1.default)({ noDb: true });
/**
* Switch Database
@@ -38,7 +39,7 @@ const grab_dsql_connection_1 = __importDefault(require("../utils/grab-dsql-conne
console.log("parsedResults =>", parsedResults);
}
catch (error) {
console.log("Connection query ERROR =>", error.message);
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Error Testing External Server`, error);
}
finally {
CONNECTION === null || CONNECTION === void 0 ? void 0 : CONNECTION.end();
+2 -1
View File
@@ -33,6 +33,7 @@ const encrypt_1 = __importDefault(require("../functions/dsql/encrypt"));
*/
function testSQLEscape() {
return __awaiter(this, void 0, void 0, function* () {
var _a;
const users = (yield (0, dbHandler_1.default)({
query: `SELECT * FROM users`,
}));
@@ -70,7 +71,7 @@ function testSQLEscape() {
console.log(`User ${user.id}: ${user.first_name} ${user.last_name} SQL credentials successfully added.`);
}
catch (error) {
console.log(`Error in adding SQL user =>`, error.message);
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Error Testing SQL Escape`, error);
}
}
process.exit();
+2 -1
View File
@@ -17,6 +17,7 @@ const fs_1 = __importDefault(require("fs"));
require("dotenv").config({ path: "./../.env" });
function updateChildrenTablesOnDb() {
return __awaiter(this, void 0, void 0, function* () {
var _a;
/**
* Grab Schema
*
@@ -48,7 +49,7 @@ function updateChildrenTablesOnDb() {
}
}
catch (error) {
console.log(error);
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Error Updating Children Tables on DB`, error);
}
process.exit();
});
@@ -32,6 +32,7 @@ const DB_HANDLER_1 = __importDefault(require("../utils/backend/global-db/DB_HAND
}).then((tables) => __awaiter(void 0, void 0, void 0, function* () {
// console.log(tables);
// process.exit();
var _a;
for (let i = 0; i < tables.length; i++) {
const table = tables[i];
try {
@@ -45,6 +46,7 @@ const DB_HANDLER_1 = __importDefault(require("../utils/backend/global-db/DB_HAND
message: error.message,
user: {},
});
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Error Updating DB Slugs For Table Records`, error);
}
}
process.exit();
+2 -2
View File
@@ -26,7 +26,7 @@ const grab_dsql_connection_1 = __importDefault(require("../utils/grab-dsql-conne
* @returns {Promise<object|null>}
*/
(() => __awaiter(void 0, void 0, void 0, function* () {
var _a;
var _a, _b;
const CONNECTION = (0, grab_dsql_connection_1.default)();
try {
const result = yield CONNECTION.query("SELECT user,host,ssl_type FROM mysql.user");
@@ -47,7 +47,7 @@ const grab_dsql_connection_1 = __importDefault(require("../utils/grab-dsql-conne
}
}
catch (error) {
console.log("Connection query ERROR =>", error.message);
(_b = global.ERROR_CALLBACK) === null || _b === void 0 ? void 0 : _b.call(global, `Error Updating SSL Users`, error);
}
finally {
CONNECTION.end();
+2
View File
@@ -22,6 +22,7 @@ const grab_dsql_connection_1 = __importDefault(require("../../utils/grab-dsql-co
*/
function dbHandler(_a) {
return __awaiter(this, arguments, void 0, function* ({ query, values, }) {
var _b;
const CONNECTION = (0, grab_dsql_connection_1.default)();
let results;
try {
@@ -33,6 +34,7 @@ function dbHandler(_a) {
}
}
catch (error) {
(_b = global.ERROR_CALLBACK) === null || _b === void 0 ? void 0 : _b.call(global, `DB Handler Error...`, error);
if (process.env.FIRST_RUN) {
return null;
}
+2 -1
View File
@@ -16,12 +16,13 @@ exports.default = noDatabaseDbHandler;
const dbHandler_1 = __importDefault(require("./dbHandler"));
function noDatabaseDbHandler(queryString) {
return __awaiter(this, void 0, void 0, function* () {
var _a;
let results;
try {
results = yield (0, dbHandler_1.default)({ query: queryString });
}
catch (error) {
console.log("ERROR in noDatabaseDbHandler =>", error.message);
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `No DB Handler Error`, error);
}
if (results) {
return results;