-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgroups.controller.ts
More file actions
90 lines (77 loc) · 2.8 KB
/
Copy pathgroups.controller.ts
File metadata and controls
90 lines (77 loc) · 2.8 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { Body, Controller, Delete, Get, Param, Patch, Post, UseGuards } from '@nestjs/common';
import { Throttle } from '@nestjs/throttler';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { CurrentUser } from '../common/decorators/current-user.decorator';
import { JwtPayload } from '../auth/types/auth.types';
import { GroupsService } from './groups.service';
import { CreateGroupDto } from './dto/create-group.dto';
import { InviteMemberDto } from './dto/invite-member.dto';
import { RemindSettlementDto } from './dto/remind-settlement.dto';
import { UpdateGroupDefaultSplitDto } from './dto/update-group-default-split.dto';
@Controller('groups')
@UseGuards(JwtAuthGuard)
export class GroupsController {
constructor(private readonly groupsService: GroupsService) {}
@Post()
create(@CurrentUser() user: JwtPayload, @Body() dto: CreateGroupDto) {
return this.groupsService.create(user.sub, dto);
}
@Get()
list(@CurrentUser() user: JwtPayload) {
return this.groupsService.list(user.sub);
}
@Get('summary')
getUserSummary(@CurrentUser() user: JwtPayload) {
return this.groupsService.getUserSummary(user.sub);
}
@Get('dashboard')
getDashboard(@CurrentUser() user: JwtPayload) {
return this.groupsService.getDashboard(user.sub);
}
@Get(':id')
getById(@Param('id') id: string, @CurrentUser() user: JwtPayload) {
return this.groupsService.getById(id, user.sub);
}
@Get(':id/members')
members(@Param('id') id: string, @CurrentUser() user: JwtPayload) {
return this.groupsService.members(id, user.sub);
}
@Get(':id/summary')
summary(@Param('id') id: string, @CurrentUser() user: JwtPayload) {
return this.groupsService.summary(id, user.sub);
}
@Patch(':id/default-split')
updateDefaultSplit(
@Param('id') id: string,
@CurrentUser() user: JwtPayload,
@Body() dto: UpdateGroupDefaultSplitDto,
) {
return this.groupsService.updateDefaultSplit(id, user.sub, dto);
}
@Post(':id/invite')
@Throttle({ default: { limit: 10, ttl: 60_000 } })
invite(@Param('id') id: string, @CurrentUser() user: JwtPayload, @Body() dto: InviteMemberDto) {
return this.groupsService.invite(id, user.sub, dto);
}
@Post(':id/remind-settlement')
@Throttle({ default: { limit: 20, ttl: 60_000 } })
remindSettlement(
@Param('id') id: string,
@CurrentUser() user: JwtPayload,
@Body() dto: RemindSettlementDto,
) {
return this.groupsService.remindSettlement(id, user.sub, dto);
}
@Patch(':id/share')
toggleShare(
@Param('id') id: string,
@CurrentUser() user: JwtPayload,
@Body('enabled') enabled: boolean,
) {
return this.groupsService.toggleShare(id, user.sub, enabled);
}
@Delete(':id')
remove(@Param('id') id: string, @CurrentUser() user: JwtPayload) {
return this.groupsService.delete(id, user.sub);
}
}