"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SolidCoreCliDBModule = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const path_1 = require("path");
const typeorm_naming_strategies_1 = require("typeorm-naming-strategies");
const winston_logger_1 = require("./winston.logger");
const nest_winston_1 = require("nest-winston");
const environment_helper_1 = require("./helpers/environment.helper");
let SolidCoreCliDBModule = class SolidCoreCliDBModule {
};
exports.SolidCoreCliDBModule = SolidCoreCliDBModule;
exports.SolidCoreCliDBModule = SolidCoreCliDBModule = __decorate([
    (0, common_1.Module)({
        imports: [
            typeorm_1.TypeOrmModule.forRootAsync({
                useFactory: (logger) => {
                    const entities = [
                        (0, path_1.join)(__dirname, './entities/*.entity.{ts,js}'),
                    ];
                    return {
                        type: 'postgres',
                        host: process.env.DEFAULT_DATABASE_HOST,
                        port: +process.env.DEFAULT_DATABASE_PORT,
                        username: process.env.DEFAULT_DATABASE_USER,
                        password: process.env.DEFAULT_DATABASE_PASSWORD,
                        database: process.env.DEFAULT_DATABASE_NAME,
                        entities: entities,
                        synchronize: (0, environment_helper_1.parseBooleanEnv)('DEFAULT_DATABASE_SYNCHRONIZE'),
                        logging: (0, environment_helper_1.parseBooleanEnv)('DEFAULT_DATABASE_LOGGING'),
                        logger: (0, environment_helper_1.parseBooleanEnv)('DEFAULT_DATABASE_LOGGING') ? new winston_logger_1.WinstonTypeORMLogger(logger) : undefined,
                        namingStrategy: new typeorm_naming_strategies_1.SnakeNamingStrategy(),
                    };
                },
                inject: [nest_winston_1.WINSTON_MODULE_PROVIDER]
            }),
        ],
    })
], SolidCoreCliDBModule);
//# sourceMappingURL=solid-core-cli-db.module.js.map