Cache driver lookup in /me controller routes #20

Closed
opened 2026-02-08 06:44:20 -08:00 by kyle · 1 comment
Owner

Context: The drivers controller has multiple /me/* routes that each independently call findByUserId() to resolve the current driver. When a driver hits several of these endpoints, the same lookup runs repeatedly.

File: backend/src/drivers/drivers.controller.ts (lines 44-49, 58-75, 83-100, 112-131)

Suggested fix:

  • Create a @CurrentDriver() param decorator (similar to @CurrentUser()) that resolves the driver once per request via middleware or interceptor
  • Or use a request-scoped cache so findByUserId() result is reused within the same request lifecycle

Effort: Small

**Context:** The drivers controller has multiple `/me/*` routes that each independently call `findByUserId()` to resolve the current driver. When a driver hits several of these endpoints, the same lookup runs repeatedly. **File:** `backend/src/drivers/drivers.controller.ts` (lines 44-49, 58-75, 83-100, 112-131) **Suggested fix:** - Create a `@CurrentDriver()` param decorator (similar to `@CurrentUser()`) that resolves the driver once per request via middleware or interceptor - Or use a request-scoped cache so `findByUserId()` result is reused within the same request lifecycle **Effort:** Small
Author
Owner

Created decorator and . Updated drivers controller /me routes to use single lookup.

Created decorator and . Updated drivers controller /me routes to use single lookup.
kyle closed this issue 2026-02-08 07:09:59 -08:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kyle/vip-coordinator#20