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

@ -53,14 +53,18 @@ export async function getStudent(username: string): Promise<StudentDTO> {
return mapToStudentDTO(user);
}
export async function createStudent(userData: StudentDTO): Promise<StudentDTO> {
export async function createOrUpdateStudent(userData: StudentDTO, options?: { preventOverwrite: boolean}): Promise<StudentDTO> {
const studentRepository = getStudentRepository();
const newStudent = mapToStudent(userData);
await studentRepository.save(newStudent, { preventOverwrite: true });
await studentRepository.save(newStudent, { preventOverwrite: options?.preventOverwrite ?? true });
return userData;
}
export async function createStudent(userData: StudentDTO): Promise<StudentDTO> {
return createOrUpdateStudent(userData, { preventOverwrite: true });
}
export async function deleteStudent(username: string): Promise<StudentDTO> {
const studentRepository = getStudentRepository();

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();