@eventstore.net/event.store
Version:
A simple and fast EventStore that support multiple persistence and notification providers
37 lines • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const Joi = require("joi");
const _ = require("lodash");
const MySQL = require("mysql");
const mySQLConfigSchema = Joi.object().keys({
cluster: Joi.object(),
config: Joi.object()
}).xor('cluster', 'config');
class MySQLFactory {
static createPool(config) {
config = MySQLFactory.validateParams(config);
let result;
if (config.cluster) {
const poolCluster = MySQL.createPoolCluster();
_.keys(config.cluster).forEach(key => {
const clusterConfig = config.cluster[key];
poolCluster.add(key, clusterConfig);
});
result = poolCluster;
}
else {
const pool = MySQL.createPool(config.config);
result = pool;
}
return result;
}
static validateParams(config) {
const result = Joi.validate(config, mySQLConfigSchema);
if (result.error) {
throw result.error;
}
return result.value;
}
}
exports.MySQLFactory = MySQLFactory;
//# sourceMappingURL=connect.js.map