I'm a junior full-stack developer from Alexandria, Egypt. This is another post about FaceMark, my face-recognition attendance system (a NestJS API plus a Python AI service). This one is about the method that writes an attendance record, and why almost none of it is the writing.
The insert is the last step
The gauntlet
When a staff member records attendance, my create() method runs five checks before it touches the database. Here they are, straight from the service:
// 1. Verify Student exists and is actually a student const student = await this . userRepo . findById ( dto . studentId ) ; if ( ! student || student . userType !== Role . STUDENT ) { throw new NotFoundException ( `Student Validation Failed: Student with ID ${dto.studentId} not found or is not registered as a student.` ) ; }
// 2. Verify Course exists const course = await this . courseRepo . findOne ( { where : { courseId : dto . courseId , isDeleted : false } , relations : [ 'enrollments' , 'instructor' ] } ) ; if ( !…