import { Controller, Get, Post, Body, Query, HttpCode } from '@nestjs/common';
import { DonationsService } from './donations.service';
import { CreateDonationDto } from './dto/create-donation.dto';

@Controller('donations')
export class DonationsController {
  constructor(private readonly donationsService: DonationsService) {}

  @Get()
  getList(@Query('limit') limit?: string) {
    const parsed = limit ? Math.min(parseInt(limit, 10) || 20, 50) : 20;
    return this.donationsService.getList(parsed);
  }

  @Post()
  @HttpCode(200)
  create(@Body() dto: CreateDonationDto) {
    return this.donationsService.create(dto);
  }
}
