import { Body, Controller, Post } from '@nestjs/common';
import { TokenExchangeService } from '../../../../libs/auth/src';
import type {
  AuthorizationCodeExchangeRequest,
  AuthorizationCodeExchangeResult,
} from '../../../../libs/auth/src';

@Controller('auth')
export class AuthSessionController {
  constructor(private readonly tokenExchange: TokenExchangeService) {}

  @Post('session')
  createSession(
    @Body() dto: AuthorizationCodeExchangeRequest,
  ): Promise<AuthorizationCodeExchangeResult> {
    return this.tokenExchange.exchangeAuthorizationCode(dto);
  }
}
