-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgroups.controller.ts
More file actions
56 lines (47 loc) · 1.95 KB
/
Copy pathgroups.controller.ts
File metadata and controls
56 lines (47 loc) · 1.95 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
import { Body, Controller, 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 { 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(':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);
}
}