github-actions[bot]
Deploy Backend from GitHub Actions Commit: ca37b2a1c9dd5c702619ea7ae7b3260d2fb5663d
b185a6d | import { | |
| Controller, | |
| Get, | |
| Post, | |
| Body, | |
| Param, | |
| Query, | |
| Delete, | |
| Put, | |
| UseGuards, | |
| Req, | |
| } from "@nestjs/common"; | |
| import { DebatesService } from "./debates.service"; | |
| import { ApiTags, ApiOperation, ApiBearerAuth } from "@nestjs/swagger"; | |
| import { JwtAuthGuard } from "../auth/jwt-auth.guard"; | |
| import { RolesGuard } from "../auth/roles.guard"; | |
| import { Roles } from "../auth/roles.decorator"; | |
| import { DebateMessageDto } from "./dto/debate-message.dto"; | |
| import { CreateDebateTopicDto } from "./dto/create-debate-topic.dto"; | |
| import { Throttle } from "@nestjs/throttler"; | |
| ("Socratic AI Debate") | |
| ("debates") | |
| (JwtAuthGuard, RolesGuard) | |
| () | |
| export class DebatesController { | |
| constructor(private debatesService: DebatesService) {} | |
| // ==================== DEBATE TOPICS / SCENARIOS (Admin & User) ==================== | |
| ("topics") | |
| ({ summary: "List all Socratic debate topics/scenarios" }) | |
| async getTopics() { | |
| return this.debatesService.getTopics(); | |
| } | |
| ("topics") | |
| ("admin") | |
| ({ summary: "Create a new debate topic (Admin)" }) | |
| async createTopic(() dto: CreateDebateTopicDto) { | |
| return this.debatesService.createTopic(dto); | |
| } | |
| ("topics/:id") | |
| ("admin") | |
| ({ summary: "Update a debate topic (Admin)" }) | |
| async updateTopic( | |
| ("id") id: string, | |
| () dto: CreateDebateTopicDto, | |
| ) { | |
| return this.debatesService.updateTopic(id, dto); | |
| } | |
| ("topics/:id") | |
| ("admin") | |
| ({ summary: "Delete a debate topic (Admin)" }) | |
| async deleteTopic(("id") id: string) { | |
| return this.debatesService.deleteTopic(id); | |
| } | |
| // ==================== TOPIC DEBATE WORKFLOW ==================== | |
| ("topic/:topicId") | |
| ({ summary: "Get or initialize a debate topic session" }) | |
| async getTopicDebate(("topicId") topicId: string, () req: any) { | |
| return this.debatesService.getOrCreateTopicDebate(topicId, req.user.id); | |
| } | |
| ("topic/:topicId/message") | |
| ({ default: { limit: 5, ttl: 60000 } }) | |
| ({ | |
| summary: "Post a user argument to a topic debate session and get rebuttal", | |
| }) | |
| async sendTopicDebateMessage( | |
| ("topicId") topicId: string, | |
| () dto: DebateMessageDto, | |
| () req: any, | |
| ) { | |
| return this.debatesService.sendTopicDebateMessage( | |
| topicId, | |
| req.user.id, | |
| dto.message, | |
| ); | |
| } | |
| // ==================== CONCEPT NODE DEBATE WORKFLOW ==================== | |
| ("all") | |
| ("admin") | |
| ({ summary: "List all Socratic debate sessions (Admin)" }) | |
| async getAllDebates() { | |
| return this.debatesService.findAll(); | |
| } | |
| (":nodeId") | |
| ({ | |
| summary: "Get or initialize a Socratic debate session transcript", | |
| }) | |
| async getDebateTranscript(("nodeId") nodeId: string, () req: any) { | |
| return this.debatesService.getOrCreateDebate(nodeId, req.user.id); | |
| } | |
| (":nodeId/message") | |
| ({ default: { limit: 5, ttl: 60000 } }) | |
| ({ summary: "Post a user argument and get a Socratic rebuttal" }) | |
| async sendDebateMessage( | |
| ("nodeId") nodeId: string, | |
| () dto: DebateMessageDto, | |
| () req: any, | |
| ) { | |
| return this.debatesService.sendDebateMessage( | |
| nodeId, | |
| req.user.id, | |
| dto.message, | |
| ); | |
| } | |
| (":id") | |
| ("admin") | |
| ({ summary: "Delete a Socratic debate session (Admin)" }) | |
| async deleteDebate(("id") id: string) { | |
| return this.debatesService.remove(id); | |
| } | |
| } | |