"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getConnection2 = exports.getConnection = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _mssql = _interopRequireDefault(require("mssql"));
var _config = _interopRequireDefault(require("../config"));
var _mssqlConectionPooling = _interopRequireDefault(require("../config/mssql-conection-pooling"));
var dbSettings = {
  user: _config["default"].userDatabase,
  password: _config["default"].passwordDatabase,
  server: _config["default"].server,
  database: _config["default"].database,
  options: {
    encrypt: true,
    trustServerCertificate: true
  }
};
var dbSettings2 = {
  user: _config["default"].userDatabase2,
  password: _config["default"].passwordDatabase2,
  server: _config["default"].server2,
  database: _config["default"].database2,
  options: {
    encrypt: true,
    trustServerCertificate: true
  }
};
var getConnection = /*#__PURE__*/function () {
  var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
    return _regenerator["default"].wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.prev = 0;
            _context.next = 3;
            return _mssqlConectionPooling["default"].GetCreateIfNotExistPool(dbSettings);
          case 3:
            return _context.abrupt("return", _context.sent);
          case 6:
            _context.prev = 6;
            _context.t0 = _context["catch"](0);
            console.log(_context.t0);
          case 9:
          case "end":
            return _context.stop();
        }
      }
    }, _callee, null, [[0, 6]]);
  }));
  return function getConnection() {
    return _ref.apply(this, arguments);
  };
}();
exports.getConnection = getConnection;
var getConnection2 = /*#__PURE__*/function () {
  var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
    return _regenerator["default"].wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            _context2.prev = 0;
            _context2.next = 3;
            return _mssqlConectionPooling["default"].GetCreateIfNotExistPool(dbSettings2);
          case 3:
            return _context2.abrupt("return", _context2.sent);
          case 6:
            _context2.prev = 6;
            _context2.t0 = _context2["catch"](0);
            console.log(_context2.t0);
          case 9:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2, null, [[0, 6]]);
  }));
  return function getConnection2() {
    return _ref2.apply(this, arguments);
  };
}();
exports.getConnection2 = getConnection2;