forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit-template.controller.ts
More file actions
33 lines (28 loc) · 1.07 KB
/
Copy pathsplit-template.controller.ts
File metadata and controls
33 lines (28 loc) · 1.07 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
import { Body, Controller, Get, Param, Post, Req } from "@nestjs/common";
import { Request } from "express";
import { SplitTemplateService } from "./split-template.service";
import { CreateSplitTemplateDto } from "./dto/create-split-template.dto";
import { CreateSplitFromTemplateDto } from "./dto/create-split-from-template.dto";
import { Split } from "../entities/split.entity";
interface RequestWithUser extends Request {
user: { wallet: string };
}
@Controller("split-templates")
export class SplitTemplateController {
constructor(private readonly service: SplitTemplateService) {}
@Post()
create(@Req() req: RequestWithUser, @Body() dto: CreateSplitTemplateDto) {
return this.service.create(req.user.wallet, dto);
}
@Get()
findAll(@Req() req: RequestWithUser) {
return this.service.findAllForUser(req.user.wallet);
}
@Post(":id/create-split")
createSplit(
@Param("id") id: string,
@Body() dto?: CreateSplitFromTemplateDto,
): Promise<Split> {
return this.service.createSplitFromTemplate(id, dto);
}
}