forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplates.controller.ts
More file actions
65 lines (57 loc) · 1.63 KB
/
Copy pathtemplates.controller.ts
File metadata and controls
65 lines (57 loc) · 1.63 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
import {
Body,
Controller,
Delete,
Get,
Param,
Post,
Put,
Query,
Req,
} from "@nestjs/common";
import { TemplateService } from "./templates.service";
import { CreateTemplateDto } from "./dtos/create-template.dto";
import { UpdateTemplateDto } from "@/recurring-splits/recurring-splits.service";
@Controller("templates")
export class TemplateController {
constructor(private readonly templateService: TemplateService) {}
@Get("suggestions")
async getSuggestions(
@Req() req: any,
@Query("participantCount") count?: number,
) {
const userId = req.user.walletAddress;
return this.templateService.getSuggestions(
userId,
count ? Number(count) : undefined,
);
}
@Post()
async create(@Req() req: any, @Body() dto: CreateTemplateDto) {
return this.templateService.create(req.user.walletAddress, dto);
}
@Get("my-templates")
async findAll(@Req() req: any) {
return this.templateService.findAll(req.user.walletAddress);
}
@Put(":id")
async update(
@Param("id") id: string,
@Req() req: any,
@Body() dto: UpdateTemplateDto,
) {
return this.templateService.update(id, req.user.walletAddress, dto);
}
@Delete(":id")
async remove(@Param("id") id: string, @Req() req: any) {
return this.templateService.remove(id, req.user.walletAddress);
}
@Post(":id/pin")
async togglePin(@Param("id") id: string, @Req() req: any) {
return this.templateService.togglePin(id, req.user.walletAddress);
}
@Post(":id/use")
async trackUsage(@Param("id") id: string, @Req() req: any) {
return this.templateService.incrementUsage(id, req.user.walletAddress);
}
}