github-actions[bot]
Deploy Backend from GitHub Actions Commit: ca37b2a1c9dd5c702619ea7ae7b3260d2fb5663d
b185a6d | import { | |
| Controller, | |
| Get, | |
| Post, | |
| Body, | |
| Param, | |
| Query, | |
| Put, | |
| Delete, | |
| UseGuards, | |
| } 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 { CreateChapterDto } from "./dto/create-chapter.dto"; | |
| import { UpdateChapterDto } from "./dto/update-chapter.dto"; | |
| ("Courses & Roadmaps") | |
| ("chapters") | |
| (JwtAuthGuard, RolesGuard) | |
| () | |
| export class ChaptersController { | |
| constructor(private coursesService: CoursesService) {} | |
| () | |
| ("admin") | |
| ({ summary: "Create a new chapter (Admin)" }) | |
| async createChapter(() dto: CreateChapterDto) { | |
| return this.coursesService.createChapter( | |
| dto.title, | |
| dto.orderIndex, | |
| dto.courseId, | |
| dto.parentChapterId, | |
| ); | |
| } | |
| () | |
| ({ summary: "List all chapters" }) | |
| async getChapters(("courseId") courseId?: string) { | |
| return this.coursesService.getChapters(courseId); | |
| } | |
| (":id") | |
| ("admin") | |
| ({ summary: "Get single chapter details (Admin)" }) | |
| async getChapterById(("id") id: string) { | |
| return this.coursesService.getChapterById(id); | |
| } | |
| (":id") | |
| ("admin") | |
| ({ summary: "Update a chapter (Admin)" }) | |
| async updateChapter(("id") id: string, () dto: UpdateChapterDto) { | |
| return this.coursesService.updateChapter( | |
| id, | |
| dto.title, | |
| dto.orderIndex, | |
| dto.parentChapterId, | |
| ); | |
| } | |
| (":id") | |
| ("admin") | |
| ({ summary: "Delete a chapter (Admin)" }) | |
| async deleteChapter(("id") id: string) { | |
| return this.coursesService.deleteChapter(id); | |
| } | |
| } | |