github-actions[bot]
Deploy Backend from GitHub Actions Commit: ca37b2a1c9dd5c702619ea7ae7b3260d2fb5663d
b185a6d | import { | |
| Controller, | |
| Get, | |
| Post, | |
| Body, | |
| Param, | |
| Query, | |
| Patch, | |
| Put, | |
| Delete, | |
| UseGuards, | |
| Req, | |
| } from "@nestjs/common"; | |
| import { CoursesService } from "./courses.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 { CreateNodeDto } from "./dto/create-node.dto"; | |
| import { UpdateNodeDto } from "./dto/update-node.dto"; | |
| import { UpdateProgressDto } from "./dto/update-progress.dto"; | |
| import { UpdateComponentProgressDto } from "./dto/update-component-progress.dto"; | |
| import { CreateWarmupDto } from "./dto/create-warmup.dto"; | |
| import { CreateCommentDto } from "./dto/create-comment.dto"; | |
| import { CreateDocumentRefDto } from "./dto/create-document-ref.dto"; | |
| ("Courses & Roadmaps") | |
| () | |
| (JwtAuthGuard, RolesGuard) | |
| () | |
| export class NodesController { | |
| constructor(private coursesService: CoursesService) {} | |
| // ==================== CONCEPT NODES ==================== | |
| ("courses/:id/journey") | |
| ({ summary: "Get course journey roadmap nodes" }) | |
| async getCourseJourney(("id") courseId: string, () req: any) { | |
| return this.coursesService.getCourseJourney(courseId, req.user.id); | |
| } | |
| ("courses/nodes/:nodeId") | |
| ({ | |
| summary: "Retrieve comprehensive learn detail for a concept node", | |
| }) | |
| async getNodeDetails(("nodeId") nodeId: string, () req: any) { | |
| return this.coursesService.getNodeDetails(nodeId, req.user.id); | |
| } | |
| ("courses/nodes/:nodeId/core") | |
| ({ | |
| summary: "Retrieve core progress and type info for a concept node", | |
| }) | |
| async getNodeCore(("nodeId") nodeId: string, () req: any) { | |
| return this.coursesService.getNodeCore(nodeId, req.user.id); | |
| } | |
| ("courses/nodes/:nodeId/complete") | |
| ({ summary: "Mark node as completed and auto-unlock next node" }) | |
| async completeNode(("nodeId") nodeId: string, () req: any) { | |
| return this.coursesService.completeNode(nodeId, req.user.id); | |
| } | |
| ("courses/nodes/:nodeId/progress") | |
| ({ summary: "Update node learn progress status" }) | |
| async updateNodeProgress( | |
| ("nodeId") nodeId: string, | |
| () dto: UpdateProgressDto, | |
| () req: any, | |
| ) { | |
| return this.coursesService.updateNodeProgress( | |
| req.user.id, | |
| nodeId, | |
| dto.status, | |
| dto.lessonCompleted, | |
| dto.flashcardCompleted, | |
| dto.podcastCompleted, | |
| dto.quizCompleted, | |
| ); | |
| } | |
| ("courses/nodes/:nodeId/component-progress") | |
| ({ summary: "Update component-based lesson progress" }) | |
| async updateComponentProgress( | |
| ("nodeId") nodeId: string, | |
| () dto: UpdateComponentProgressDto, | |
| () req: any, | |
| ) { | |
| return this.coursesService.updateComponentProgress( | |
| req.user.id, | |
| nodeId, | |
| dto.activeComponentId, | |
| dto.currentComponentIndex, | |
| dto.completedComponentIds, | |
| dto.componentResult, | |
| ); | |
| } | |
| ("nodes") | |
| ("admin") | |
| ({ summary: "Create a new concept node (Admin)" }) | |
| async createNode(() dto: CreateNodeDto) { | |
| return this.coursesService.createNode(dto); | |
| } | |
| ("nodes") | |
| ("admin") | |
| ({ summary: "List all concept nodes (Admin)" }) | |
| async getNodes(("chapterId") chapterId?: string) { | |
| return this.coursesService.getNodes(chapterId); | |
| } | |
| ("nodes/:nodeId") | |
| ("admin") | |
| ({ summary: "Update a concept node (Admin)" }) | |
| async updateNode( | |
| ("nodeId") nodeId: string, | |
| () dto: UpdateNodeDto, | |
| ) { | |
| return this.coursesService.updateNode(nodeId, dto); | |
| } | |
| ("nodes/:nodeId") | |
| ("admin") | |
| ({ summary: "Delete a concept node (Admin)" }) | |
| async deleteNode(("nodeId") nodeId: string) { | |
| return this.coursesService.deleteNode(nodeId); | |
| } | |
| // ==================== WARMUPS ==================== | |
| ("nodes/:nodeId/warmups") | |
| ("admin") | |
| ({ summary: "Create a new warmup for a concept node (Admin)" }) | |
| async createWarmup( | |
| ("nodeId") nodeId: string, | |
| () dto: CreateWarmupDto, | |
| ) { | |
| return this.coursesService.createWarmup(nodeId, dto); | |
| } | |
| ("nodes/:nodeId/warmups") | |
| ({ summary: "List all warmups for a concept node" }) | |
| async getWarmups(("nodeId") nodeId: string) { | |
| return this.coursesService.getWarmups(nodeId); | |
| } | |
| ("warmups/:id") | |
| ("admin") | |
| ({ summary: "Delete a warmup by ID (Admin)" }) | |
| async deleteWarmup(("id") id: string) { | |
| return this.coursesService.deleteWarmup(id); | |
| } | |
| // ==================== DISCUSSIONS / COMMENTS ==================== | |
| ("courses/nodes/:nodeId/comments") | |
| ({ summary: "Post a comment on a concept node discussion" }) | |
| async createComment( | |
| ("nodeId") nodeId: string, | |
| () dto: CreateCommentDto, | |
| () req: any, | |
| ) { | |
| const role = req.user.role === "admin" ? "admin" : "student"; | |
| return this.coursesService.createComment( | |
| nodeId, | |
| req.user.id, | |
| dto.content, | |
| role, | |
| ); | |
| } | |
| ("courses/nodes/:nodeId/comments") | |
| ({ summary: "Get all comments for a concept node discussion" }) | |
| async getComments(("nodeId") nodeId: string) { | |
| return this.coursesService.getComments(nodeId); | |
| } | |
| // ==================== PDF REFERENCE DOCUMENTS CRUD ==================== | |
| ("documents") | |
| ("admin") | |
| ({ summary: "Save a PDF document reference" }) | |
| async createDocument(() dto: CreateDocumentRefDto) { | |
| return this.coursesService.createDocument( | |
| dto.courseId, | |
| dto.fileName, | |
| dto.fileUrl, | |
| dto.status, | |
| dto.title, | |
| dto.description, | |
| ); | |
| } | |
| ("documents") | |
| ({ summary: "List all reference PDF documents" }) | |
| async listDocuments(("courseId") courseId?: string) { | |
| return this.coursesService.listDocuments(courseId); | |
| } | |
| ("documents/:id") | |
| ("admin") | |
| ({ summary: "Delete a PDF reference document by ID" }) | |
| async deleteDocument(("id") id: string) { | |
| return this.coursesService.deleteDocument(id); | |
| } | |
| } | |