"use strict";
/**
 * 车场镜像库
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateMySqlKnexInstance = exports.knexInstance = void 0;
var mslib_1 = require("mslib");
var typescript_ioc_1 = require("typescript-ioc");
var Contants_1 = require("./Contants");
/**
 * 镜像车场knex实例
 *
 * 模块被加载时，从ioc读取配置config.parkImageKnex并自动创建该实例，如果未配置则为空
 *
 * 具体配置参考官方文档
 *
 * https://www.npmjs.com/package/knex
 */
exports.knexInstance = null;
var config = typescript_ioc_1.Container.getValue('config.parkImageKnex');
if (config) {
    exports.knexInstance = generateMySqlKnexInstance(config);
}
function generateMySqlKnexInstance(config) {
    var defaults = {
        client: 'mysql2',
        pool: { min: 0, max: 10 },
        debug: Contants_1.default.IS_DEBUG,
        log: {
            warn: function (message) {
                mslib_1.logger.warn(message);
            },
            error: function (message) {
                mslib_1.logger.error(message);
            },
            deprecate: function (message) {
                mslib_1.logger.error(message);
            },
            debug: function (message) {
                mslib_1.logger.debug(message);
            },
        }
    };
    return require('knex')(Object.assign(defaults, config));
}
exports.generateMySqlKnexInstance = generateMySqlKnexInstance;
//# sourceMappingURL=ParkImage.js.map