import { Controller, Get } from "@nestjs/common";
import { JwksService } from "./jwks.service.js";
import type { JwksResponse } from "./jwks.service.js";

/**
 * JWKS 端点（president §2.15 + I7）。
 *
 * 路径：GET /v1/iam/.well-known/jwks.json
 * 公开端点，无需鉴权（Gateway 启动时拉取并缓存公钥用于验签）。
 *
 * gateway 路由：/iam/v1/.well-known/jwks.json → iam /v1/iam/.well-known/jwks.json
 */
@Controller("v1/iam")
export class JwksController {
  constructor(private readonly jwksService: JwksService) {}

  @Get(".well-known/jwks.json")
  jwks(): JwksResponse {
    return this.jwksService.getJwks();
  }
}
