Menu

Five things my API checks before it writes one attendance record: validation in a real NestJS servinestjs,typescript,webdev,beginners,ce
📰

Five things my API checks before it writes one attendance record: validation in a real NestJS servinestjs,typescript,webdev,beginners,ce

DEV Community: nestjs·Ziad Taha·6 days ago
#MMKYpjxT
#devtonestjs#devto#dev#student#staff
Long article (1066 words) — no AI summary yet.
Reading 0:00
15s threshold

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 ( !…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.