25 lines
1 KiB
TypeScript
25 lines
1 KiB
TypeScript
import { Get, Body, Post, Route, Tags, SuccessResponse, Response, Delete, Controller, Security, Request, Put, Path } from 'tsoa';
|
|
import { ValidationError } from '../middleware/errorHandler';
|
|
import { createCourse, createCourseResponse, listCourseResponse } from '../types/courses.types';
|
|
import { CoursesService } from '../services/courses.service';
|
|
import { get } from 'http';
|
|
|
|
@Route('api/courses')
|
|
@Tags('Courses')
|
|
export class CoursesController extends Controller {
|
|
private coursesService = new CoursesService();
|
|
|
|
@Get()
|
|
@SuccessResponse('200', 'Courses fetched successfully')
|
|
@Response('401', 'Invalid or expired token')
|
|
public async listCourses(): Promise<listCourseResponse> {
|
|
return await this.coursesService.ListCourses();
|
|
}
|
|
|
|
@Get('{id}')
|
|
@SuccessResponse('200', 'Course fetched successfully')
|
|
@Response('401', 'Invalid or expired token')
|
|
public async getCourseById(@Path() id: number): Promise<listCourseResponse> {
|
|
return await this.coursesService.ListCourses();
|
|
}
|
|
}
|