Updates
This commit is contained in:
@@ -2,4 +2,4 @@
|
||||
* # DSQL user read-only DB handler
|
||||
* @requires DSQL_DB_CONN - Gobal Variable for Datasquirel Database
|
||||
*/
|
||||
export default function DB_HANDLER(...args: any[]): Promise<any>;
|
||||
export default function DB_HANDLER(query: string, values?: any[]): Promise<any>;
|
||||
|
||||
@@ -18,14 +18,14 @@ const grab_dsql_connection_1 = __importDefault(require("../../grab-dsql-connecti
|
||||
* # DSQL user read-only DB handler
|
||||
* @requires DSQL_DB_CONN - Gobal Variable for Datasquirel Database
|
||||
*/
|
||||
function DB_HANDLER(...args) {
|
||||
function DB_HANDLER(query, values) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const CONNECTION = (0, grab_dsql_connection_1.default)();
|
||||
try {
|
||||
if (!CONNECTION)
|
||||
throw new Error("No Connection provided to DB_HANDLER function!");
|
||||
const results = yield CONNECTION.query(...args);
|
||||
const results = yield CONNECTION.query(query, values);
|
||||
return JSON.parse(JSON.stringify(results));
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
*/
|
||||
export default function LOCAL_DB_HANDLER(...args: any[]): Promise<any>;
|
||||
export default function LOCAL_DB_HANDLER(query: string, values?: any[]): Promise<any>;
|
||||
|
||||
@@ -17,12 +17,12 @@ const grab_dsql_connection_1 = __importDefault(require("../../grab-dsql-connecti
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
*/
|
||||
function LOCAL_DB_HANDLER(...args) {
|
||||
function LOCAL_DB_HANDLER(query, values) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
var _a;
|
||||
const MASTER = (0, grab_dsql_connection_1.default)();
|
||||
try {
|
||||
const results = yield MASTER.query(...args);
|
||||
const results = yield MASTER.query(query, values);
|
||||
return JSON.parse(JSON.stringify(results));
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
*/
|
||||
export default function NO_DB_HANDLER(...args: any[]): Promise<unknown> | {
|
||||
export default function NO_DB_HANDLER(query: string, values?: any[]): Promise<unknown> | {
|
||||
success: boolean;
|
||||
error: any;
|
||||
};
|
||||
|
||||
@@ -8,12 +8,12 @@ const grab_dsql_connection_1 = __importDefault(require("../../grab-dsql-connecti
|
||||
/**
|
||||
* # DSQL user read-only DB handler
|
||||
*/
|
||||
function NO_DB_HANDLER(...args) {
|
||||
function NO_DB_HANDLER(query, values) {
|
||||
var _a;
|
||||
const CONNECTION = (0, grab_dsql_connection_1.default)();
|
||||
try {
|
||||
return new Promise((resolve, reject) => {
|
||||
CONNECTION.query(...args)
|
||||
CONNECTION.query(query, values)
|
||||
.then((results) => {
|
||||
CONNECTION.end();
|
||||
resolve(JSON.parse(JSON.stringify(results)));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* # Root DB handler
|
||||
*/
|
||||
export default function ROOT_DB_HANDLER(...args: any[]): Promise<unknown> | {
|
||||
export default function ROOT_DB_HANDLER(query: string, values?: any[]): Promise<unknown> | {
|
||||
success: boolean;
|
||||
error: any;
|
||||
};
|
||||
|
||||
@@ -8,12 +8,12 @@ const grab_dsql_connection_1 = __importDefault(require("../../grab-dsql-connecti
|
||||
/**
|
||||
* # Root DB handler
|
||||
*/
|
||||
function ROOT_DB_HANDLER(...args) {
|
||||
function ROOT_DB_HANDLER(query, values) {
|
||||
var _a;
|
||||
const CONNECTION = (0, grab_dsql_connection_1.default)();
|
||||
try {
|
||||
return new Promise((resolve, reject) => {
|
||||
CONNECTION.query(...args)
|
||||
CONNECTION.query(query, values)
|
||||
.then((results) => {
|
||||
CONNECTION.end();
|
||||
resolve(JSON.parse(JSON.stringify(results)));
|
||||
|
||||
+3
-4
@@ -1,8 +1,7 @@
|
||||
type Return = string | (import("tls").SecureContextOptions & {
|
||||
rejectUnauthorized?: boolean | undefined;
|
||||
}) | undefined;
|
||||
import type { ConnectionConfig } from "mariadb";
|
||||
type Return = ConnectionConfig["ssl"] | undefined;
|
||||
/**
|
||||
* # Grall SSL
|
||||
* # Grab SSL
|
||||
*/
|
||||
export default function grabDbSSL(): Return;
|
||||
export {};
|
||||
|
||||
+6
-7
@@ -5,23 +5,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = grabDbSSL;
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const grab_dir_names_1 = __importDefault(require("./names/grab-dir-names"));
|
||||
/**
|
||||
* # Grall SSL
|
||||
* # Grab SSL
|
||||
*/
|
||||
function grabDbSSL() {
|
||||
const SSL_DIR = process.env.DSQL_SSL_DIR;
|
||||
if (!(SSL_DIR === null || SSL_DIR === void 0 ? void 0 : SSL_DIR.match(/./))) {
|
||||
const { maxscaleSSLDir } = (0, grab_dir_names_1.default)();
|
||||
if (!(maxscaleSSLDir === null || maxscaleSSLDir === void 0 ? void 0 : maxscaleSSLDir.match(/./))) {
|
||||
return undefined;
|
||||
}
|
||||
const caFilePath = `${SSL_DIR}/ca-cert.pem`;
|
||||
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(`${SSL_DIR}/ca-cert.pem`),
|
||||
// key: fs.readFileSync(`${SSL_DIR}/client-key.pem`),
|
||||
// cert: fs.readFileSync(`${SSL_DIR}/client-cert.pem`),
|
||||
ca: fs_1.default.readFileSync(`${maxscaleSSLDir}/ca-cert.pem`),
|
||||
rejectUnauthorized: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -65,5 +65,9 @@ export default function grabDirNames(param?: Param): {
|
||||
sqlBackupDirName: string;
|
||||
schemasBackupDirName: string;
|
||||
userMainShemaJSONFilePath: string | undefined;
|
||||
maxscaleSSLDir: string;
|
||||
mainDBSSLDir: string;
|
||||
replica1DBSSLDir: string;
|
||||
replica2DBSSLDir: string;
|
||||
};
|
||||
export {};
|
||||
|
||||
@@ -20,6 +20,10 @@ 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 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 privateDataDir = path_1.default.join(DATA_DIR, "private");
|
||||
/**
|
||||
* # DB Dir names
|
||||
@@ -175,5 +179,9 @@ function grabDirNames(param) {
|
||||
sqlBackupDirName,
|
||||
schemasBackupDirName,
|
||||
userMainShemaJSONFilePath,
|
||||
maxscaleSSLDir,
|
||||
mainDBSSLDir,
|
||||
replica1DBSSLDir,
|
||||
replica2DBSSLDir,
|
||||
};
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
export default function grabDockerStackServicesNames(): {
|
||||
deploymentName: string;
|
||||
maxScaleServiceName: string;
|
||||
dbServiceName: string;
|
||||
dbCronServiceName: string;
|
||||
postDbSetupServiceName: string;
|
||||
webAppServiceName: string;
|
||||
webAppCronServiceName: string;
|
||||
webAppPostDbSetupServiceName: string;
|
||||
dbReplica1ServiceName: string;
|
||||
dbReplica2ServiceName: string;
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = grabDockerStackServicesNames;
|
||||
function grabDockerStackServicesNames() {
|
||||
const deploymentName = process.env.DSQL_DEPLOYMENT_NAME || "dsql";
|
||||
const maxScaleServiceName = `${deploymentName}-dsql-maxscale`;
|
||||
const dbServiceName = `${deploymentName}-dsql-db`;
|
||||
const dbCronServiceName = `${deploymentName}-dsql-db-cron`;
|
||||
const postDbSetupServiceName = `${deploymentName}-dsql-post-db-setup`;
|
||||
const webAppServiceName = `${deploymentName}-dsql-web-app`;
|
||||
const webAppCronServiceName = `${deploymentName}-dsql-web-app-cron`;
|
||||
const webAppPostDbSetupServiceName = `${deploymentName}-dsql-web-app-post-db-setup`;
|
||||
const dbReplica1ServiceName = `${deploymentName}-dsql-db-replica-1`;
|
||||
const dbReplica2ServiceName = `${deploymentName}-dsql-db-replica-2`;
|
||||
return {
|
||||
deploymentName,
|
||||
maxScaleServiceName,
|
||||
dbServiceName,
|
||||
dbCronServiceName,
|
||||
postDbSetupServiceName,
|
||||
webAppServiceName,
|
||||
webAppCronServiceName,
|
||||
webAppPostDbSetupServiceName,
|
||||
dbReplica1ServiceName,
|
||||
dbReplica2ServiceName,
|
||||
};
|
||||
}
|
||||
@@ -2,5 +2,7 @@ export default function grabIPAddresses(): {
|
||||
webAppIP: string;
|
||||
appCronIP: string;
|
||||
maxScaleIP: string;
|
||||
mainDBIP: string;
|
||||
localHostIP: string;
|
||||
globalIPPrefix: string;
|
||||
};
|
||||
|
||||
@@ -11,5 +11,14 @@ function grabIPAddresses() {
|
||||
const webAppIP = `${globalIPPrefix}.${web}`;
|
||||
const appCronIP = `${globalIPPrefix}.${cron}`;
|
||||
const maxScaleIP = `${globalIPPrefix}.${maxscale}`;
|
||||
return { webAppIP, appCronIP, maxScaleIP, globalIPPrefix };
|
||||
const mainDBIP = `${globalIPPrefix}.${db}`;
|
||||
const localHostIP = `${globalIPPrefix}.1`;
|
||||
return {
|
||||
webAppIP,
|
||||
appCronIP,
|
||||
maxScaleIP,
|
||||
mainDBIP,
|
||||
localHostIP,
|
||||
globalIPPrefix,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user