"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
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;
};
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppModule = void 0;
const common_1 = require("@nestjs/common");
const config_1 = require("@nestjs/config");
const platform_express_1 = require("@nestjs/platform-express");
const schedule_1 = require("@nestjs/schedule");
const throttler_1 = require("@nestjs/throttler");
const typeorm_1 = require("@nestjs/typeorm");
const app_controller_1 = require("./app.controller");
const app_service_1 = require("./app.service");
const config_2 = require("./config");
const mail_service_1 = require("./config/mails/mail.service");
const upload_service_1 = require("./config/multer/upload.service");
const access_control_module_1 = require("./modules/access-control/access-control.module");
const timezone_module_1 = require("./common/timezone/timezone.module");
const attendance_module_1 = require("./modules/attendance/attendance.module");
const ip_whitelist_module_1 = require("./modules/ip-whitelist/ip-whitelist.module");
const devices_module_1 = require("./modules/devices/devices.module");
const calendar_module_1 = require("./modules/calendar/calendar.module");
const configurations_module_1 = require("./modules/configurations/configurations.module");
const dashboard_module_1 = require("./modules/dashboard/dashboard.module");
const departments_module_1 = require("./modules/departments/departments.module");
const designations_module_1 = require("./modules/designations/designations.module");
const employement_types_module_1 = require("./modules/employement_types/employement_types.module");
const events_module_1 = require("./modules/events/events.module");
const hiring_sources_module_1 = require("./modules/hiring_sources/hiring_sources.module");
const holidays_module_1 = require("./modules/holidays/holidays.module");
const leaves_module_1 = require("./modules/leaves/leaves.module");
const locations_module_1 = require("./modules/locations/locations.module");
const members_module_1 = require("./modules/members/members.module");
const notice_module_1 = require("./modules/notice/notice.module");
const notifications_module_1 = require("./modules/notifications/notifications.module");
const notifications_service_1 = require("./modules/notifications/notifications.service");
const owner_module_1 = require("./modules/owner/owner.module");
const recruitment_module_1 = require("./modules/recruitment/recruitment.module");
const onboarding_module_1 = require("./modules/onboarding/onboarding.module");
const probation_module_1 = require("./modules/probation/probation.module");
const offboarding_module_1 = require("./modules/offboarding/offboarding.module");
const notification_socket_1 = require("./notification.socket");
const Entities = __importStar(require("./config/database/entities"));
let AppModule = class AppModule {
    constructor(configService) {
        this.configService = configService;
    }
    onModuleInit() {
        config_2.AppConfig.initialize(this.configService);
    }
};
exports.AppModule = AppModule;
exports.AppModule = AppModule = __decorate([
    (0, common_1.Module)({
        imports: [
            config_1.ConfigModule.forRoot({
                isGlobal: true,
                load: [config_2.envConfig],
            }),
            typeorm_1.TypeOrmModule.forRootAsync({
                inject: [config_1.ConfigService],
                useFactory: (configService) => {
                    const url = configService.get('db.url') || (0, config_2.envConfig)().db.url;
                    return {
                        type: 'mysql',
                        ...(url
                            ? { url }
                            : {
                                host: configService.get('db.host') || (0, config_2.envConfig)().db.host,
                                port: configService.get('db.port') || (0, config_2.envConfig)().db.port,
                                username: configService.get('db.username') || (0, config_2.envConfig)().db.username,
                                password: configService.get('db.password') || (0, config_2.envConfig)().db.password,
                                database: configService.get('db.database') || (0, config_2.envConfig)().db.database,
                            }),
                        entities: Object.values(Entities).filter((item) => typeof item === 'function'),
                        synchronize: false,
                        logging: configService.get('db.logging') === 'true',
                    };
                },
            }),
            throttler_1.ThrottlerModule.forRootAsync({
                useFactory: async (configService) => {
                    const ttl = configService.get('throttle.ttl') || 60000;
                    const limit = configService.get('throttle.limit') || 5;
                    return {
                        throttlers: [
                            {
                                ttl,
                                limit,
                            },
                        ],
                    };
                },
                inject: [config_1.ConfigService],
            }),
            schedule_1.ScheduleModule.forRoot(),
            timezone_module_1.TimezoneModule,
            owner_module_1.OwnerModule,
            members_module_1.MembersModule,
            departments_module_1.DepartmentsModule,
            designations_module_1.DesignationsModule,
            locations_module_1.LocationsModule,
            employement_types_module_1.EmployementTypesModule,
            hiring_sources_module_1.HiringSourcesModule,
            attendance_module_1.AttendanceModule,
            ip_whitelist_module_1.IpWhitelistModule,
            devices_module_1.DevicesModule,
            leaves_module_1.LeavesModule,
            holidays_module_1.HolidaysModule,
            events_module_1.EventsModule,
            configurations_module_1.ConfigurationsModule,
            notice_module_1.NoticeModule,
            dashboard_module_1.DashboardModule,
            calendar_module_1.CalendarModule,
            notifications_module_1.NotificationsModule,
            access_control_module_1.AccessControlModule,
            recruitment_module_1.RecruitmentModule,
            onboarding_module_1.OnboardingModule,
            probation_module_1.ProbationModule,
            offboarding_module_1.OffboardingModule,
        ],
        controllers: [app_controller_1.AppController],
        providers: [
            app_service_1.AppService,
            mail_service_1.MailService,
            upload_service_1.UploadService,
            config_2.DatabaseService,
            notifications_service_1.NotificationsService,
            notification_socket_1.NotificationGateway,
            {
                provide: 'APP_INTERCEPTOR',
                useClass: (0, platform_express_1.FileFieldsInterceptor)([
                    { name: 'image', maxCount: 1 },
                    { name: 'document', maxCount: 1 },
                    { name: 'documents' },
                    { name: 'thumbnail', maxCount: 1 },
                    { name: 'file' },
                    { name: 'files', maxCount: 10 },
                ]),
            },
        ],
        exports: [mail_service_1.MailService, upload_service_1.UploadService],
    }),
    __metadata("design:paramtypes", [config_1.ConfigService])
], AppModule);
//# sourceMappingURL=app.module.js.map