feat(backend): '/auth/hello' endpoint toegevoegd

This commit is contained in:
Gerald Schmittinger 2025-04-19 11:27:51 +02:00
parent c2f3a6169a
commit 2b3f6b5e7a
6 changed files with 40 additions and 7 deletions

View file

@ -57,14 +57,18 @@ export async function getTeacher(username: string): Promise<TeacherDTO> {
return mapToTeacherDTO(user);
}
export async function createTeacher(userData: TeacherDTO): Promise<TeacherDTO> {
export async function createOrUpdateTeacher(userData: TeacherDTO, options?: { preventOverwrite?: boolean }): Promise<TeacherDTO> {
const teacherRepository: TeacherRepository = getTeacherRepository();
const newTeacher = mapToTeacher(userData);
await teacherRepository.save(newTeacher, { preventOverwrite: true });
await teacherRepository.save(newTeacher, { preventOverwrite: options?.preventOverwrite ?? true });
return mapToTeacherDTO(newTeacher);
}
export async function createTeacher(userData: TeacherDTO): Promise<TeacherDTO> {
return await createOrUpdateTeacher(userData, { preventOverwrite: true });
}
export async function deleteTeacher(username: string): Promise<TeacherDTO> {
const teacherRepository: TeacherRepository = getTeacherRepository();