exams setup
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import express from "express";
|
||||
import { Body, Controller, Get, Path, Post, Query, Request, Route } from "tsoa";
|
||||
import type {
|
||||
ExamCreationDto,
|
||||
ExamDto,
|
||||
ExamWithMembersDto,
|
||||
MemberExamCreationDto,
|
||||
MemberExamDto,
|
||||
} from "../dtos/examDto.js";
|
||||
import { inject } from "../infrastructure/di/index.js";
|
||||
import { ExamsService } from "../services/examsService.js";
|
||||
|
||||
@Route("exams")
|
||||
export class ExamsController extends Controller {
|
||||
private readonly examsService = inject(ExamsService);
|
||||
|
||||
@Post()
|
||||
public async createExam(
|
||||
@Request() request: express.Request,
|
||||
@Body() newExam: ExamCreationDto,
|
||||
): Promise<ExamDto> {
|
||||
return await this.examsService.createExam(newExam, request);
|
||||
}
|
||||
|
||||
@Get("latest")
|
||||
public async getLatestExam(
|
||||
@Request() request: express.Request,
|
||||
): Promise<ExamWithMembersDto | null> {
|
||||
return await this.examsService.getLatest(request);
|
||||
}
|
||||
|
||||
@Post("register/{examId}")
|
||||
public async registerForExam(
|
||||
@Request() request: express.Request,
|
||||
@Body() newRegistration: MemberExamCreationDto
|
||||
): Promise<MemberExamDto> {
|
||||
return await this.examsService.register(newRegistration, request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user