import { Module } from "@nestjs/common";
import { APP_GUARD } from "@nestjs/core";
import { UsersModule } from "@bff/modules/users/users.module.js";
import { TokensModule } from "../tokens/tokens.module.js";
import { GlobalAuthGuard } from "../presentation/http/guards/global-auth.guard.js";
import { PermissionsGuard } from "../presentation/http/guards/permissions.guard.js";
import { AuthRateLimitService } from "../infra/rate-limiting/auth-rate-limit.service.js";

@Module({
  imports: [TokensModule, UsersModule],
  providers: [
    GlobalAuthGuard,
    PermissionsGuard,
    AuthRateLimitService,
    {
      provide: APP_GUARD,
      useClass: GlobalAuthGuard,
    },
    {
      provide: APP_GUARD,
      useClass: PermissionsGuard,
    },
  ],
  exports: [GlobalAuthGuard, PermissionsGuard, AuthRateLimitService],
})
export class SharedAuthModule {}
