Updates
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
import { ConnectionConfig } from "mariadb";
|
||||
import { DsqlConnectionParam } from "../types";
|
||||
/**
|
||||
* # Grab General CONNECTION for DSQL
|
||||
*/
|
||||
export default function grabDSQLConnectionConfig(param?: DsqlConnectionParam): ConnectionConfig;
|
||||
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = grabDSQLConnectionConfig;
|
||||
const grabDbSSL_1 = __importDefault(require("./backend/grabDbSSL"));
|
||||
/**
|
||||
* # Grab General CONNECTION for DSQL
|
||||
*/
|
||||
function grabDSQLConnectionConfig(param) {
|
||||
const CONN_TIMEOUT = 10000;
|
||||
const config = Object.assign({ host: process.env.DSQL_DB_HOST, user: process.env.DSQL_DB_USERNAME, password: process.env.DSQL_DB_PASSWORD, database: (param === null || param === void 0 ? void 0 : param.database) ||
|
||||
((param === null || param === void 0 ? void 0 : param.noDb) ? undefined : process.env.DSQL_DB_NAME), port: process.env.DSQL_DB_PORT
|
||||
? Number(process.env.DSQL_DB_PORT)
|
||||
: undefined, charset: "utf8mb4", ssl: (0, grabDbSSL_1.default)(), bigIntAsNumber: true, supportBigNumbers: true, bigNumberStrings: false, dateStrings: true, metaAsArray: true, socketTimeout: CONN_TIMEOUT, connectTimeout: CONN_TIMEOUT, compress: true }, param === null || param === void 0 ? void 0 : param.config);
|
||||
return config;
|
||||
}
|
||||
+3
-17
@@ -1,20 +1,6 @@
|
||||
import { Connection, ConnectionConfig } from "mariadb";
|
||||
type Param = {
|
||||
/**
|
||||
* No Database Connection
|
||||
*/
|
||||
noDb?: boolean;
|
||||
/**
|
||||
* Database Name
|
||||
*/
|
||||
database?: string;
|
||||
/**
|
||||
* Debug
|
||||
*/
|
||||
config?: ConnectionConfig;
|
||||
};
|
||||
import { Connection } from "mariadb";
|
||||
import { DsqlConnectionParam } from "../types";
|
||||
/**
|
||||
* # Grab General CONNECTION for DSQL
|
||||
*/
|
||||
export default function grabDSQLConnection(param?: Param): Promise<Connection>;
|
||||
export {};
|
||||
export default function grabDSQLConnection(param?: DsqlConnectionParam): Promise<Connection>;
|
||||
|
||||
+2
-78
@@ -14,17 +14,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = grabDSQLConnection;
|
||||
const mariadb_1 = __importDefault(require("mariadb"));
|
||||
const grabDbSSL_1 = __importDefault(require("./backend/grabDbSSL"));
|
||||
const grab_dsql_connection_config_1 = __importDefault(require("./grab-dsql-connection-config"));
|
||||
/**
|
||||
* # Grab General CONNECTION for DSQL
|
||||
*/
|
||||
function grabDSQLConnection(param) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const CONN_TIMEOUT = 10000;
|
||||
const config = Object.assign({ host: process.env.DSQL_DB_HOST, user: process.env.DSQL_DB_USERNAME, password: process.env.DSQL_DB_PASSWORD, database: (param === null || param === void 0 ? void 0 : param.database) ||
|
||||
((param === null || param === void 0 ? void 0 : param.noDb) ? undefined : process.env.DSQL_DB_NAME), port: process.env.DSQL_DB_PORT
|
||||
? Number(process.env.DSQL_DB_PORT)
|
||||
: undefined, charset: "utf8mb4", ssl: (0, grabDbSSL_1.default)(), bigIntAsNumber: true, supportBigNumbers: true, bigNumberStrings: false, dateStrings: true, metaAsArray: true, socketTimeout: CONN_TIMEOUT, connectTimeout: CONN_TIMEOUT, compress: true }, param === null || param === void 0 ? void 0 : param.config);
|
||||
const config = (0, grab_dsql_connection_config_1.default)(param);
|
||||
try {
|
||||
return yield mariadb_1.default.createConnection(config);
|
||||
}
|
||||
@@ -32,77 +28,5 @@ function grabDSQLConnection(param) {
|
||||
console.log(`Error Grabbing DSQL Connection =>`, config);
|
||||
throw error;
|
||||
}
|
||||
// if (global.DSQL_USE_LOCAL || param?.local) {
|
||||
// return (
|
||||
// global.DSQL_DB_CONN ||
|
||||
// (await mariadb.createConnection({
|
||||
// host: process.env.DSQL_DB_HOST,
|
||||
// user: process.env.DSQL_DB_USERNAME,
|
||||
// password: process.env.DSQL_DB_PASSWORD,
|
||||
// database: param?.noDb ? undefined : process.env.DSQL_DB_NAME,
|
||||
// port: process.env.DSQL_DB_PORT
|
||||
// ? Number(process.env.DSQL_DB_PORT)
|
||||
// : undefined,
|
||||
// charset: "utf8mb4",
|
||||
// ssl: grabDbSSL(),
|
||||
// supportBigNumbers: true,
|
||||
// bigNumberStrings: false,
|
||||
// dateStrings: true,
|
||||
// }))
|
||||
// );
|
||||
// }
|
||||
// if (param?.ro) {
|
||||
// return (
|
||||
// global.DSQL_READ_ONLY_DB_CONN ||
|
||||
// (await mariadb.createConnection({
|
||||
// host: process.env.DSQL_DB_HOST,
|
||||
// user: process.env.DSQL_DB_READ_ONLY_USERNAME,
|
||||
// password: process.env.DSQL_DB_READ_ONLY_PASSWORD,
|
||||
// port: process.env.DSQL_DB_PORT
|
||||
// ? Number(process.env.DSQL_DB_PORT)
|
||||
// : undefined,
|
||||
// charset: "utf8mb4",
|
||||
// ssl: grabDbSSL(),
|
||||
// supportBigNumbers: true,
|
||||
// bigNumberStrings: false,
|
||||
// dateStrings: true,
|
||||
// }))
|
||||
// );
|
||||
// }
|
||||
// if (param?.fa) {
|
||||
// return (
|
||||
// global.DSQL_FULL_ACCESS_DB_CONN ||
|
||||
// (await mariadb.createConnection({
|
||||
// host: process.env.DSQL_DB_HOST,
|
||||
// user: process.env.DSQL_DB_FULL_ACCESS_USERNAME,
|
||||
// password: process.env.DSQL_DB_FULL_ACCESS_PASSWORD,
|
||||
// port: process.env.DSQL_DB_PORT
|
||||
// ? Number(process.env.DSQL_DB_PORT)
|
||||
// : undefined,
|
||||
// charset: "utf8mb4",
|
||||
// ssl: grabDbSSL(),
|
||||
// supportBigNumbers: true,
|
||||
// bigNumberStrings: false,
|
||||
// dateStrings: true,
|
||||
// }))
|
||||
// );
|
||||
// }
|
||||
// return (
|
||||
// global.DSQL_DB_CONN ||
|
||||
// (await mariadb.createConnection({
|
||||
// host: process.env.DSQL_DB_HOST,
|
||||
// user: process.env.DSQL_DB_USERNAME,
|
||||
// password: process.env.DSQL_DB_PASSWORD,
|
||||
// database: param?.noDb ? undefined : process.env.DSQL_DB_NAME,
|
||||
// port: process.env.DSQL_DB_PORT
|
||||
// ? Number(process.env.DSQL_DB_PORT)
|
||||
// : undefined,
|
||||
// charset: "utf8mb4",
|
||||
// ssl: grabDbSSL(),
|
||||
// supportBigNumbers: true,
|
||||
// bigNumberStrings: false,
|
||||
// dateStrings: true,
|
||||
// }))
|
||||
// );
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user