32 lines
1.5 KiB
JavaScript
32 lines
1.5 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.default = setupDSQLDb;
|
|
const grabDbSSL_1 = __importDefault(require("./backend/grabDbSSL"));
|
|
const mariadb_1 = __importDefault(require("mariadb"));
|
|
function setupDSQLDb({ useLocal, dbConfig, ssl, connectionLimit = 100, }) {
|
|
global.DSQL_USE_LOCAL = useLocal || true;
|
|
const pool = mariadb_1.default.createPool(Object.assign(Object.assign({ host: process.env.DSQL_DB_HOST, user: process.env.DSQL_DB_USERNAME, password: process.env.DSQL_DB_PASSWORD, database: process.env.DSQL_DB_NAME, charset: "utf8mb4" }, dbConfig), { ssl: ssl ? (0, grabDbSSL_1.default)() : undefined, connectionLimit }));
|
|
global.DSQL_DB_CONN = pool;
|
|
// let readOnlyConnection;
|
|
// if (addReadOnlyConn) {
|
|
// readOnlyConnection = mariadb.createPool({
|
|
// host: process.env.DSQL_DB_HOST,
|
|
// user: process.env.DSQL_DB_READ_ONLY_USERNAME,
|
|
// password: process.env.DSQL_DB_READ_ONLY_PASSWORD,
|
|
// database: process.env.DSQL_DB_NAME,
|
|
// charset: "utf8mb4",
|
|
// ...readOnlyDbConfig,
|
|
// ssl: ssl ? grabDbSSL() : undefined,
|
|
// connectionLimit,
|
|
// });
|
|
// global.DSQL_READ_ONLY_DB_CONN = readOnlyConnection;
|
|
// }
|
|
return {
|
|
pool,
|
|
// readOnlyConnection,
|
|
};
|
|
}
|