All files / modules/billing/controllers plans.controller.ts

0% Statements 0/13
100% Branches 0/0
0% Functions 0/3
0% Lines 0/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51                                                                                                     
import { Controller, Get, Param } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiParam } from '@nestjs/swagger';
import { PlansService } from '../services/plans.service';
import { PlanResponseDto, PlanDetailResponseDto } from '../dto/plan-response.dto';
import { Public } from '../../auth/decorators/public.decorator';
 
@ApiTags('plans')
@Controller('plans')
export class PlansController {
  constructor(private readonly plansService: PlansService) {}
 
  @Get()
  @Public()
  @ApiOperation({
    summary: 'List all available plans',
    description: 'Returns all visible and active pricing plans ordered by sort_order',
  })
  @ApiResponse({
    status: 200,
    description: 'List of available plans',
    type: [PlanResponseDto],
  })
  async findAll(): Promise<PlanResponseDto[]> {
    return this.plansService.findAll();
  }
 
  @Get(':id')
  @Public()
  @ApiOperation({
    summary: 'Get a single plan by ID',
    description: 'Returns detailed information about a specific plan',
  })
  @ApiParam({
    name: 'id',
    description: 'Plan UUID',
    type: 'string',
  })
  @ApiResponse({
    status: 200,
    description: 'Plan details',
    type: PlanDetailResponseDto,
  })
  @ApiResponse({
    status: 404,
    description: 'Plan not found',
  })
  async findOne(@Param('id') id: string): Promise<PlanDetailResponseDto> {
    return this.plansService.findOne(id);
  }
}