All checks were successful
ci/woodpecker/push/ci Pipeline was successful
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Post,
|
|
Patch,
|
|
Delete,
|
|
Body,
|
|
Param,
|
|
UseGuards,
|
|
ParseUUIDPipe,
|
|
} from "@nestjs/common";
|
|
import { UserAgentService } from "./user-agent.service";
|
|
import { CreateUserAgentDto } from "./dto/create-user-agent.dto";
|
|
import { UpdateUserAgentDto } from "./dto/update-user-agent.dto";
|
|
import { AuthGuard } from "../auth/guards/auth.guard";
|
|
import { CurrentUser } from "../auth/decorators/current-user.decorator";
|
|
import type { AuthUser } from "@mosaic/shared";
|
|
|
|
@Controller("agents")
|
|
@UseGuards(AuthGuard)
|
|
export class UserAgentController {
|
|
constructor(private readonly userAgentService: UserAgentService) {}
|
|
|
|
@Get()
|
|
findAll(@CurrentUser() user: AuthUser) {
|
|
return this.userAgentService.findAll(user.id);
|
|
}
|
|
|
|
@Get(":id")
|
|
findOne(@CurrentUser() user: AuthUser, @Param("id", ParseUUIDPipe) id: string) {
|
|
return this.userAgentService.findOne(user.id, id);
|
|
}
|
|
|
|
@Post()
|
|
create(@CurrentUser() user: AuthUser, @Body() dto: CreateUserAgentDto) {
|
|
return this.userAgentService.create(user.id, dto);
|
|
}
|
|
|
|
@Post("from-template/:templateId")
|
|
createFromTemplate(
|
|
@CurrentUser() user: AuthUser,
|
|
@Param("templateId", ParseUUIDPipe) templateId: string
|
|
) {
|
|
return this.userAgentService.createFromTemplate(user.id, templateId);
|
|
}
|
|
|
|
@Patch(":id")
|
|
update(
|
|
@CurrentUser() user: AuthUser,
|
|
@Param("id", ParseUUIDPipe) id: string,
|
|
@Body() dto: UpdateUserAgentDto
|
|
) {
|
|
return this.userAgentService.update(user.id, id, dto);
|
|
}
|
|
|
|
@Delete(":id")
|
|
remove(@CurrentUser() user: AuthUser, @Param("id", ParseUUIDPipe) id: string) {
|
|
return this.userAgentService.remove(user.id, id);
|
|
}
|
|
}
|