/**
 * @aurora-catalyst-generated
 * @source cliter/iam/account.aurora.yaml
 */
import { IamAccount } from '@api/graphql';
import { IamAccountDto } from '@api/iam/account';
import { IamMeAccountHandler } from '@app/iam/account';
import { Auth } from '@aurora/decorators';
import { CurrentAccount } from '@aurorajs.dev/core-back';
import { Controller, Get, HttpCode } from '@nestjs/common';
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('[iam] account')
@Controller('iam/account/me')
@Auth()
export class IamMeAccountController {
  constructor(private readonly handler: IamMeAccountHandler) {}

  @Get()
  @HttpCode(200)
  @ApiOperation({ summary: 'Get the authenticated account' })
  @ApiOkResponse({
    description: 'The operation has been successfully executed.',
    type: IamAccountDto,
  })
  async main(@CurrentAccount() currentAccount: IamAccount): Promise<IamAccount> {
    return await this.handler.main(currentAccount);
  }
}
