/*
 * Copyright 2025 Daytona Platforms Inc.
 * SPDX-License-Identifier: AGPL-3.0
 */

import { Controller, Get, Logger, HttpCode } from '@nestjs/common'
import { ApiResponse, ApiOperation, ApiTags } from '@nestjs/swagger'
import { RegionDto } from '../dto/region.dto'
import { RegionType } from '../enums/region-type.enum'
import { RegionService } from '../services/region.service'
import { Public } from '../../auth/decorators/public.decorator'

@Controller('shared-regions')
@ApiTags('regions')
@Public()
export class RegionController {
  private readonly logger = new Logger(RegionController.name)

  constructor(private readonly regionService: RegionService) {}

  @Get()
  @HttpCode(200)
  @ApiOperation({
    summary: 'List all shared regions',
    operationId: 'listSharedRegions',
  })
  @ApiResponse({
    status: 200,
    description: 'List of all shared regions',
    type: [RegionDto],
  })
  async listRegions(): Promise<RegionDto[]> {
    return this.regionService.findAllByRegionType(RegionType.SHARED)
  }
}
