import { Controller, Get, Query } from "@nestjs/common";
import { ApiOperation, ApiTags } from "@nestjs/swagger";
import { Public } from "@edr/api-common";

import { CheckAvailabilityService } from "./check-availability.service";

@ApiTags("auth")
@Controller("auth")
@Public()
export class CheckAvailabilityController {
  constructor(
    private readonly checkAvailabilityService: CheckAvailabilityService,
  ) {}

  @Get("check-availability")
  @ApiOperation({
    summary: "Check whether an email and/or phone number is already registered",
  })
  check(@Query("email") email?: string, @Query("phone") phone?: string) {
    return this.checkAvailabilityService.check({ email, phone });
  }
}
