Updates
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
* @requires DSQL_DB_CONN - Gobal Variable for Datasquirel Database
|
||||
*/
|
||||
export default function DB_HANDLER(query: string, values?: any[]): Promise<any>;
|
||||
@@ -1,47 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = DB_HANDLER;
|
||||
const grab_dsql_connection_1 = __importDefault(require("../../grab-dsql-connection"));
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
* @requires DSQL_DB_CONN - Gobal Variable for Datasquirel Database
|
||||
*/
|
||||
function DB_HANDLER(query, values) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const CONNECTION = yield (0, grab_dsql_connection_1.default)();
|
||||
try {
|
||||
if (!CONNECTION)
|
||||
throw new Error("No Connection provided to DB_HANDLER function!");
|
||||
const results = yield CONNECTION.query(query, values);
|
||||
if (Array.isArray(results)) {
|
||||
return Array.from(results);
|
||||
}
|
||||
else {
|
||||
return results;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `DB_HANDLER Error`, error);
|
||||
return {
|
||||
success: false,
|
||||
error: error.message,
|
||||
};
|
||||
}
|
||||
finally {
|
||||
yield (CONNECTION === null || CONNECTION === void 0 ? void 0 : CONNECTION.end());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
type Param = {
|
||||
paradigm: "Full Access" | "FA" | "Read Only";
|
||||
queryString: string;
|
||||
queryValues?: string[];
|
||||
};
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
*/
|
||||
export default function DSQL_USER_DB_HANDLER({ paradigm, queryString, queryValues, }: Param): Promise<any>;
|
||||
export {};
|
||||
@@ -1,38 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = DSQL_USER_DB_HANDLER;
|
||||
const conn_db_handler_1 = __importDefault(require("../../db/conn-db-handler"));
|
||||
const grab_dsql_connection_1 = __importDefault(require("../../grab-dsql-connection"));
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
*/
|
||||
function DSQL_USER_DB_HANDLER(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ paradigm, queryString, queryValues, }) {
|
||||
var _b;
|
||||
const CONNECTION = paradigm == "Read Only"
|
||||
? yield (0, grab_dsql_connection_1.default)({ ro: true })
|
||||
: yield (0, grab_dsql_connection_1.default)({ fa: true });
|
||||
try {
|
||||
return yield (0, conn_db_handler_1.default)(CONNECTION, queryString, queryValues);
|
||||
}
|
||||
catch (error) {
|
||||
(_b = global.ERROR_CALLBACK) === null || _b === void 0 ? void 0 : _b.call(global, `DSQL_USER_DB_HANDLER Error`, error);
|
||||
return null;
|
||||
}
|
||||
finally {
|
||||
yield (CONNECTION === null || CONNECTION === void 0 ? void 0 : CONNECTION.end());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
*/
|
||||
export default function LOCAL_DB_HANDLER(query: string, values?: any[]): Promise<any>;
|
||||
@@ -1,44 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = LOCAL_DB_HANDLER;
|
||||
const grab_dsql_connection_1 = __importDefault(require("../../grab-dsql-connection"));
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
*/
|
||||
function LOCAL_DB_HANDLER(query, values) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const CONNECTION = yield (0, grab_dsql_connection_1.default)();
|
||||
try {
|
||||
const results = yield CONNECTION.query(query, values);
|
||||
if (Array.isArray(results)) {
|
||||
return Array.from(results);
|
||||
}
|
||||
else {
|
||||
return results;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `LOCAL_DB_HANDLER Error`, error);
|
||||
return {
|
||||
success: false,
|
||||
error: error.message,
|
||||
};
|
||||
}
|
||||
finally {
|
||||
yield (CONNECTION === null || CONNECTION === void 0 ? void 0 : CONNECTION.end());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
*/
|
||||
export default function NO_DB_HANDLER(query: string, values?: any[]): Promise<unknown>;
|
||||
@@ -1,54 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = NO_DB_HANDLER;
|
||||
const grab_dsql_connection_1 = __importDefault(require("../../grab-dsql-connection"));
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
*/
|
||||
function NO_DB_HANDLER(query, values) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const CONNECTION = yield (0, grab_dsql_connection_1.default)();
|
||||
try {
|
||||
return new Promise((resolve, reject) => {
|
||||
CONNECTION.query(query, values)
|
||||
.then((results) => __awaiter(this, void 0, void 0, function* () {
|
||||
if (Array.isArray(results)) {
|
||||
resolve(Array.from(results));
|
||||
}
|
||||
else {
|
||||
resolve(results);
|
||||
}
|
||||
}))
|
||||
.catch((err) => __awaiter(this, void 0, void 0, function* () {
|
||||
resolve({
|
||||
error: err.message,
|
||||
sql: err.sql,
|
||||
});
|
||||
}))
|
||||
.finally(() => __awaiter(this, void 0, void 0, function* () {
|
||||
yield (CONNECTION === null || CONNECTION === void 0 ? void 0 : CONNECTION.end());
|
||||
}));
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `NO_DB_HANDLER Error`, error);
|
||||
return {
|
||||
success: false,
|
||||
error: error.message,
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
+4
-4
@@ -10,17 +10,17 @@ const grab_dir_names_1 = __importDefault(require("./names/grab-dir-names"));
|
||||
* # Grab SSL
|
||||
*/
|
||||
function grabDbSSL() {
|
||||
const { maxscaleSSLDir } = (0, grab_dir_names_1.default)();
|
||||
if (!(maxscaleSSLDir === null || maxscaleSSLDir === void 0 ? void 0 : maxscaleSSLDir.match(/./))) {
|
||||
const { maxscaleSSLCaCertFile } = (0, grab_dir_names_1.default)();
|
||||
const caFilePath = process.env.DSQL_SSL_CA_CERT || maxscaleSSLCaCertFile;
|
||||
if (!(caFilePath === null || caFilePath === void 0 ? void 0 : caFilePath.match(/./))) {
|
||||
return undefined;
|
||||
}
|
||||
const caFilePath = `${maxscaleSSLDir}/ca-cert.pem`;
|
||||
if (!fs_1.default.existsSync(caFilePath)) {
|
||||
console.log(`${caFilePath} does not exist`);
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
ca: fs_1.default.readFileSync(`${maxscaleSSLDir}/ca-cert.pem`),
|
||||
ca: fs_1.default.readFileSync(caFilePath),
|
||||
rejectUnauthorized: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ function importMariadbDatabase(_a) {
|
||||
const finalMariadbUser = mariadbUser || process.env.DSQL_DB_USERNAME;
|
||||
const finalMariadbHost = mariadbHost || process.env.DSQL_DB_HOST;
|
||||
const finalMariadbPass = mariadbPass || process.env.DSQL_DB_PASSWORD;
|
||||
yield (0, conn_db_handler_1.default)(global.DSQL_DB_CONN, `CREATE DATABASE IF NOT EXISTS ${dbFullName}`);
|
||||
yield (0, conn_db_handler_1.default)(null, `CREATE DATABASE IF NOT EXISTS ${dbFullName}`);
|
||||
const cmd = `${mysqlPath} -u ${finalMariadbUser} -h ${finalMariadbHost} -p"${finalMariadbPass}" ${dbFullName} < ${targetFilePath}`;
|
||||
let execSyncOptions = {
|
||||
encoding: "utf-8",
|
||||
|
||||
@@ -67,6 +67,7 @@ export default function grabDirNames(param?: Param): {
|
||||
schemasBackupDirName: string;
|
||||
userMainShemaJSONFilePath: string | undefined;
|
||||
maxscaleSSLDir: string;
|
||||
maxscaleSSLCaCertFile: string;
|
||||
mainDBSSLDir: string;
|
||||
replica1DBSSLDir: string;
|
||||
replica2DBSSLDir: string;
|
||||
@@ -89,5 +90,13 @@ export default function grabDirNames(param?: Param): {
|
||||
distroEnterpriseExportTarName: "dsql-enterprise.tar.xz";
|
||||
communityDistroTempDir: string;
|
||||
communityDistroDir: string;
|
||||
installScriptFile: string;
|
||||
updateScriptFile: string;
|
||||
installTypescriptFile: string;
|
||||
updateTypescriptFile: string;
|
||||
dsqlDbDockerComposeFile: string;
|
||||
dsqlDbDockerComposeFileAlt: string;
|
||||
dsqlDbDockerComposeFileName: string;
|
||||
dsqlDbDockerComposeFileNameAlt: string;
|
||||
};
|
||||
export {};
|
||||
|
||||
+22
-2
@@ -26,10 +26,15 @@ function grabDirNames(param) {
|
||||
const publicSSLDir = path_1.default.join(publicDir, "documents", "ssl");
|
||||
const appSSLDir = path_1.default.join(appDir, "ssl");
|
||||
const mainSSLDir = path_1.default.join(DATA_DIR, "ssl");
|
||||
const installScriptFile = path_1.default.join(appDir, "scripts", "shell", "installation", "install.sh");
|
||||
const updateScriptFile = path_1.default.join(appDir, "scripts", "shell", "installation", "update.sh");
|
||||
const installTypescriptFile = path_1.default.join(appDir, "scripts", "shell", "installation", "install.ts");
|
||||
const updateTypescriptFile = path_1.default.join(appDir, "scripts", "shell", "installation", "update.ts");
|
||||
const maxscaleSSLDir = path_1.default.join(mainSSLDir, "maxscale");
|
||||
const mainDBSSLDir = path_1.default.join(mainSSLDir, "main");
|
||||
const replica1DBSSLDir = path_1.default.join(mainSSLDir, "replica-1");
|
||||
const replica2DBSSLDir = path_1.default.join(mainSSLDir, "replica-2");
|
||||
const maxscaleSSLCaCertFile = path_1.default.join(maxscaleSSLDir, "ca-cert.pem");
|
||||
const privateDataDir = path_1.default.join(DATA_DIR, "private");
|
||||
/**
|
||||
* # DB Dir names
|
||||
@@ -106,12 +111,18 @@ function grabDirNames(param) {
|
||||
const dbNginxLoadBalancerConfigFile = path_1.default.join(appDir, "docker/services/mariadb/load-balancer/config/template/nginx.conf");
|
||||
let dockerComposeFile = path_1.default.join(appDir, "docker-compose.yml");
|
||||
let dockerComposeFileAlt = path_1.default.join(appDir, "docker-compose.yaml");
|
||||
const dbDockerComposeFileName = "db.docker-compose.yml";
|
||||
const dbDockerComposeFileNameAlt = "db.docker-compose.yaml";
|
||||
const dsqlDockerComposeFileName = "dsql.docker-compose.yml";
|
||||
const dsqlDockerComposeFileNameAlt = "dsql.docker-compose.yaml";
|
||||
const dsqlDbDockerComposeFileName = "dsql-db.docker-compose.yml";
|
||||
const dsqlDbDockerComposeFileNameAlt = "dsql-db.docker-compose.yaml";
|
||||
const dsqlDockerComposeFile = path_1.default.join(appDir, dsqlDockerComposeFileName);
|
||||
const dsqlDockerComposeFileAlt = path_1.default.join(appDir, dsqlDockerComposeFileNameAlt);
|
||||
const dbDockerComposeFile = path_1.default.join(appDir, "db.docker-compose.yml");
|
||||
const dbDockerComposeFileAlt = path_1.default.join(appDir, "db.docker-compose.yaml");
|
||||
const dbDockerComposeFile = path_1.default.join(appDir, dbDockerComposeFileName);
|
||||
const dbDockerComposeFileAlt = path_1.default.join(appDir, dbDockerComposeFileNameAlt);
|
||||
const dsqlDbDockerComposeFile = path_1.default.join(appDir, dsqlDbDockerComposeFileName);
|
||||
const dsqlDbDockerComposeFileAlt = path_1.default.join(appDir, dsqlDbDockerComposeFileNameAlt);
|
||||
const extraDockerComposeFile = path_1.default.join(appDir, "extra.docker-compose.yml");
|
||||
const extraDockerComposeFileAlt = path_1.default.join(appDir, "extra.docker-compose.yaml");
|
||||
const siteSetupFile = path_1.default.join(appDir, "site-setup.json");
|
||||
@@ -204,6 +215,7 @@ function grabDirNames(param) {
|
||||
schemasBackupDirName,
|
||||
userMainShemaJSONFilePath,
|
||||
maxscaleSSLDir,
|
||||
maxscaleSSLCaCertFile,
|
||||
mainDBSSLDir,
|
||||
replica1DBSSLDir,
|
||||
replica2DBSSLDir,
|
||||
@@ -226,5 +238,13 @@ function grabDirNames(param) {
|
||||
distroEnterpriseExportTarName,
|
||||
communityDistroTempDir,
|
||||
communityDistroDir,
|
||||
installScriptFile,
|
||||
updateScriptFile,
|
||||
installTypescriptFile,
|
||||
updateTypescriptFile,
|
||||
dsqlDbDockerComposeFile,
|
||||
dsqlDbDockerComposeFileAlt,
|
||||
dsqlDbDockerComposeFileName,
|
||||
dsqlDbDockerComposeFileNameAlt,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,4 +6,5 @@ export default function grabIPAddresses(): {
|
||||
localHostIP: string;
|
||||
globalIPPrefix: string;
|
||||
webSocketIP: string;
|
||||
dbCronIP: string;
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@ function grabIPAddresses() {
|
||||
const maxScaleIP = `${globalIPPrefix}.${maxscale}`;
|
||||
const mainDBIP = `${globalIPPrefix}.${db}`;
|
||||
const webSocketIP = `${globalIPPrefix}.${websocket}`;
|
||||
const dbCronIP = `${globalIPPrefix}.${db_cron}`;
|
||||
const localHostIP = `${globalIPPrefix}.1`;
|
||||
return {
|
||||
webAppIP,
|
||||
@@ -22,5 +23,6 @@ function grabIPAddresses() {
|
||||
localHostIP,
|
||||
globalIPPrefix,
|
||||
webSocketIP,
|
||||
dbCronIP,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ exports.default = parseCookies;
|
||||
* returns the cookies as a JS object
|
||||
*/
|
||||
function parseCookies({ request, cookieString, }) {
|
||||
var _a;
|
||||
try {
|
||||
/** @type {string | undefined} */
|
||||
const cookieStr = request
|
||||
@@ -37,7 +36,6 @@ function parseCookies({ request, cookieString, }) {
|
||||
return cookieObject;
|
||||
}
|
||||
catch (error) {
|
||||
(_a = global.ERROR_CALLBACK) === null || _a === void 0 ? void 0 : _a.call(global, `Parse Cookies Error`, error);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user