forked from MergeFi/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbounties.controller.ts
More file actions
52 lines (44 loc) · 1.44 KB
/
Copy pathbounties.controller.ts
File metadata and controls
52 lines (44 loc) · 1.44 KB
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
52
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { IsString } from 'class-validator';
import { BountiesService } from './bounties.service';
import { CreateBountyDto } from './dto/create-bounty.dto';
import { ClaimBountyDto } from './dto/claim-bounty.dto';
import { BountyStatus } from '../common/enums';
import { Idempotent } from '../common/idempotency/idempotent.decorator';
class FundBountyDto {
@IsString()
funderAddress: string;
}
@ApiTags('bounties')
@Controller('bounties')
export class BountiesController {
constructor(private readonly bountiesService: BountiesService) {}
@Post()
create(@Body() dto: CreateBountyDto) {
return this.bountiesService.create(dto);
}
@Get()
list(@Query('status') status?: BountyStatus) {
return this.bountiesService.list(status);
}
@Get(':id')
findOne(@Param('id') id: string) {
return this.bountiesService.findOne(id);
}
@Idempotent('bounty.fund')
@Post(':id/fund')
fund(@Param('id') id: string, @Body() dto: FundBountyDto) {
return this.bountiesService.fund(id, dto.funderAddress);
}
@Idempotent('bounty.claim')
@Post(':id/claim')
claim(@Param('id') id: string, @Body() dto: ClaimBountyDto) {
return this.bountiesService.claim(id, dto.contributorId);
}
@Idempotent('bounty.refund')
@Post(':id/refund')
refund(@Param('id') id: string) {
return this.bountiesService.refund(id);
}
}