forked from MergeFi/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmilestones.controller.ts
More file actions
67 lines (57 loc) · 1.65 KB
/
Copy pathmilestones.controller.ts
File metadata and controls
67 lines (57 loc) · 1.65 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { IsOptional, IsString, IsUUID } from 'class-validator';
import { MilestonesService } from './milestones.service';
import { CreateMilestoneDto } from './dto/create-milestone.dto';
import { Idempotent } from '../common/idempotency/idempotent.decorator';
class FundMilestoneDto {
@IsString()
funderAddress: string;
}
class ResolveIssueDto {
@IsString()
recipientAddress: string;
@IsOptional()
@IsUUID()
recipientId?: string;
}
@ApiTags('milestones')
@Controller('milestones')
export class MilestonesController {
constructor(private readonly milestonesService: MilestonesService) {}
@Post()
create(@Body() dto: CreateMilestoneDto) {
return this.milestonesService.create(dto);
}
@Get()
list() {
return this.milestonesService.list();
}
@Get(':id')
findOne(@Param('id') id: string) {
return this.milestonesService.findOne(id);
}
@Idempotent('milestone.fund')
@Post(':id/fund')
fund(@Param('id') id: string, @Body() dto: FundMilestoneDto) {
return this.milestonesService.fund(id, dto.funderAddress);
}
@Post(':id/issues/:issueId')
addIssue(@Param('id') id: string, @Param('issueId') issueId: string) {
return this.milestonesService.addIssue(id, issueId);
}
@Idempotent('milestone.resolveIssue')
@Post(':id/issues/:issueId/resolve')
resolveIssue(
@Param('id') id: string,
@Param('issueId') issueId: string,
@Body() dto: ResolveIssueDto,
) {
return this.milestonesService.resolveIssue(
id,
issueId,
dto.recipientAddress,
dto.recipientId,
);
}
}