fix: appointment conflict detection, soft-delete, and auth guardrail (#18-22) #24
Reference in New Issue
Block a user
Delete Branch "fix/appointment-bugs-and-auth-guardrail"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes five bugs flagged in the CEO code review, all of which were merged without fixes in PRs #15 and #16.
#18 — Race condition in conflict detection: The
hasConflictcheck and subsequent INSERT/UPDATE are now wrapped in adb.transaction()call, preventing two concurrent requests from both passing the conflict check and creating double-bookings.#19 — PATCH skips conflict when staffId omitted: The condition now falls back to the existing appointment's
staffIdwhen the field is absent from the request body. Rescheduling an appointment without resendingstaffIdcorrectly checks conflicts against the already-assigned groomer.#20 — DELETE hard-removes records:
DELETE /appointments/:idnow setsstatus = 'cancelled'instead of removing the row, preserving audit trail and financial records.#21 — Staff DELETE ignores active appointments:
DELETE /staff/:idnow checks for existing non-cancelled appointments referencing the staff member and returns409with a clear message if any exist.#22 — AUTH_DISABLED has no production guardrail: On module load, if
AUTH_DISABLED=trueis set, the API now:NODE_ENV=production): logs a fatal error and callsprocess.exit(1).Files changed
apps/api/src/routes/appointments.ts— transaction wrapping, PATCH conflict fix, soft-deleteapps/api/src/routes/staff.ts— appointment check before staff deleteapps/api/src/middleware/auth.ts— production guardrail for AUTH_DISABLEDTest plan
cancelledAUTH_DISABLED=trueandNODE_ENV=production— process should exit with errorAUTH_DISABLED=trueandNODE_ENV=development— should log warning and startCloses #18, #19, #20, #21, #22
🤖 Generated with Claude Code