import { Module } from "@nestjs/common";
import { IamController } from "./iam.controller.js";
import { RbacController } from "./rbac.controller.js";
import { AuditController } from "./audit.controller.js";
import { JwksController } from "./jwks.controller.js";
import { IamGrpcController } from "./iam.grpc.controller.js";
import { IamService } from "./iam.service.js";
import { IamRepository } from "./iam.repository.js";
import { JwksService } from "./jwks.service.js";
import { PermissionCacheService } from "../shared/cache/permission-cache.service.js";
import { TokenBlacklistService } from "../shared/cache/token-blacklist.service.js";

@Module({
  controllers: [IamController, RbacController, AuditController, JwksController],
  providers: [
    IamService,
    IamRepository,
    JwksService,
    PermissionCacheService,
    TokenBlacklistService,
    IamGrpcController,
  ],
  // 导出 PermissionCacheService 与 IamRepository，供在 AppModule 级别注册的
  // APP_GUARD（PermissionGuard）注入使用。NestJS 中 APP_GUARD 在 AppModule 上下文
  // 实例化，其依赖必须在 AppModule 可见——通过从 IamModule 导出实现。
  exports: [PermissionCacheService, IamRepository],
})
export class IamModule {}
