"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 config_1 = require("@nestjs/config");
const typeorm_1 = require("@nestjs/typeorm");
const jwt_1 = require("@nestjs/jwt");
const throttler_1 = require("@nestjs/throttler");
const schedule_1 = require("@nestjs/schedule");
const core_1 = require("@nestjs/core");
const serve_static_1 = require("@nestjs/serve-static");
const path_1 = require("path");
const auth_module_1 = require("./auth/auth.module");
const mail_module_1 = require("./mail/mail.module");
const banners_module_1 = require("./banners/banners.module");
const marquees_module_1 = require("./marquees/marquees.module");
const settings_module_1 = require("./settings/settings.module");
const testimonials_module_1 = require("./testimonials/testimonials.module");
const admin_module_1 = require("./admin/admin.module");
const categories_module_1 = require("./categories/categories.module");
const secondary_banners_module_1 = require("./secondary-banners/secondary-banners.module");
const backing_module_1 = require("./backing/backing.module");
const plans_module_1 = require("./plans/plans.module");
const auth_middleware_1 = require("./common/middleware/auth.middleware");
let AppModule = class AppModule {
    configure(consumer) {
        consumer.apply(auth_middleware_1.AuthMiddleware).forRoutes("*");
    }
};
exports.AppModule = AppModule;
exports.AppModule = AppModule = __decorate([
    (0, common_1.Module)({
        imports: [
            config_1.ConfigModule.forRoot({ isGlobal: true }),
            throttler_1.ThrottlerModule.forRoot([
                {
                    ttl: 60000,
                    limit: 100,
                },
            ]),
            schedule_1.ScheduleModule.forRoot(),
            serve_static_1.ServeStaticModule.forRoot({
                rootPath: (0, path_1.join)(__dirname, "..", "uploads"),
                serveRoot: "/uploads",
            }),
            jwt_1.JwtModule.registerAsync({
                imports: [config_1.ConfigModule],
                inject: [config_1.ConfigService],
                useFactory: (config) => ({
                    secret: config.get("JWT_SECRET"),
                    signOptions: { expiresIn: "15m" },
                }),
                global: true,
            }),
            typeorm_1.TypeOrmModule.forRootAsync({
                imports: [config_1.ConfigModule],
                inject: [config_1.ConfigService],
                useFactory: (config) => ({
                    type: "postgres",
                    host: config.get("DB_HOST", "localhost"),
                    port: config.get("DB_PORT", 5432),
                    username: config.get("DB_USERNAME", "postgres"),
                    password: config.get("DB_PASSWORD", "postgres"),
                    database: config.get("DB_DATABASE", "lotifyx"),
                    autoLoadEntities: true,
                    synchronize: config.get("NODE_ENV") !== "production",
                }),
            }),
            auth_module_1.AuthModule,
            mail_module_1.MailModule,
            banners_module_1.BannersModule,
            marquees_module_1.MarqueesModule,
            settings_module_1.SettingsModule,
            testimonials_module_1.TestimonialsModule,
            admin_module_1.AdminModule,
            categories_module_1.CategoriesModule,
            secondary_banners_module_1.SecondaryBannersModule,
            backing_module_1.BackingModule,
            plans_module_1.PlansModule,
        ],
        providers: [
            {
                provide: core_1.APP_GUARD,
                useClass: throttler_1.ThrottlerGuard,
            },
        ],
    })
], AppModule);
//# sourceMappingURL=app.module.js.map