"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.AppModule = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const schedule_1 = require("@nestjs/schedule");
const config_module_1 = require("./common/config/config.module");
const config_service_1 = require("./common/config/config.service");
const database_module_1 = require("./database/database.module");
const auth_module_1 = require("./auth/auth.module");
const mpesa_module_1 = require("./mpesa/mpesa.module");
const packages_module_1 = require("./packages/packages.module");
const payments_module_1 = require("./payments/payments.module");
const sessions_module_1 = require("./sessions/sessions.module");
const customers_module_1 = require("./customers/customers.module");
const vouchers_module_1 = require("./vouchers/vouchers.module");
const business_module_1 = require("./business/business.module");
const admin_module_1 = require("./admin/admin.module");
const notifications_module_1 = require("./notifications/notifications.module");
const reports_module_1 = require("./reports/reports.module");
const subscriptions_module_1 = require("./subscriptions/subscriptions.module");
const jobs_module_1 = require("./jobs/jobs.module");
const audit_module_1 = require("./audit/audit.module");
const settings_module_1 = require("./settings/settings.module");
const captive_module_1 = require("./captive/captive.module");
const locations_module_1 = require("./locations/locations.module");
const router_module_1 = require("./router/router.module");
let AppModule = class AppModule {
};
exports.AppModule = AppModule;
exports.AppModule = AppModule = __decorate([
    (0, common_1.Module)({
        imports: [
            config_module_1.ConfigModule,
            schedule_1.ScheduleModule.forRoot(),
            typeorm_1.TypeOrmModule.forRootAsync({
                imports: [config_module_1.ConfigModule],
                inject: [config_service_1.ConfigService],
                useFactory: (config) => ({
                    type: config.get('DB_TYPE', 'mysql'),
                    host: config.get('DB_HOST', 'localhost'),
                    port: parseInt(config.get('DB_PORT', '3306'), 10),
                    username: config.get('DB_USERNAME', 'hbs_user'),
                    password: config.get('DB_PASSWORD', 'hbs_password'),
                    database: config.get('DB_NAME', 'hbs_db'),
                    entities: [__dirname + '/**/*.entity{.ts,.js}'],
                    synchronize: config.get('NODE_ENV') === 'development',
                    logging: config.get('NODE_ENV') === 'development' ? ['error', 'warn'] : ['error'],
                    ssl: config.get('DB_SSL') === 'true' ? { rejectUnauthorized: false } : false,
                }),
            }),
            database_module_1.DatabaseModule,
            auth_module_1.AuthModule,
            mpesa_module_1.MpesaModule,
            packages_module_1.PackagesModule,
            payments_module_1.PaymentsModule,
            sessions_module_1.SessionsModule,
            customers_module_1.CustomersModule,
            vouchers_module_1.VouchersModule,
            business_module_1.BusinessModule,
            admin_module_1.AdminModule,
            notifications_module_1.NotificationsModule,
            reports_module_1.ReportsModule,
            subscriptions_module_1.SubscriptionsModule,
            jobs_module_1.JobsModule,
            audit_module_1.AuditModule,
            settings_module_1.SettingsModule,
            captive_module_1.CaptiveModule,
            locations_module_1.LocationsModule,
            router_module_1.RouterModule,
        ],
    })
], AppModule);
