brackt/app/routes/api
Chris Parsons 686ccd7188
Add TypeScript types and improve draft validation (#28)
* Code review fixes: type safety, security hardening, and dead code removal

- Fix Socket.IO event types: draft-paused and draft-resumed were typed as
  () => void but are emitted with { seasonId, paused } data payloads

- Fix draft.force-manual-pick: add missing season.status === "draft" guard
  so commissioners cannot force picks outside an active draft; add duplicate
  pick-number check so a slot cannot be assigned two picks (the previous
  code only checked participant uniqueness, not slot uniqueness)

- Replace args: any with ActionFunctionArgs / Route.LoaderArgs across all
  API routes and league loaders; replace (auth as any).userId casts with
  proper const { userId } = await getAuth(args) destructuring

- Remove unused isSnakeDraft = true dead variable from draft.make-pick

- Replace autodraftSettings: any and draftSlots: any[] in draft-utils with
  properly typed InferSelectModel / DraftSlot types

- Update force-manual-pick tests: sequence draftPicks.findFirst mock for
  the two-call flow; add new tests for status-check and slot-uniqueness

https://claude.ai/code/session_01FKq2gPFYpgdfxr8cw4Z2AZ

* Fix RouterContextProvider type errors in action test files

Cast context argument to RouterContextProvider in test helpers so
ActionFunctionArgs strict typing is satisfied without weakening the
production action signatures back to any.

https://claude.ai/code/session_01FKq2gPFYpgdfxr8cw4Z2AZ

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-22 19:26:45 -08:00
..
__tests__ Add TypeScript types and improve draft validation (#28) 2026-02-22 19:26:45 -08:00
webhooks refactor: simplify user update logic in Clerk webhook handler to reuse findOrCreateUser 2025-10-14 21:50:07 -07:00
autodraft.update.ts Add TypeScript types and improve draft validation (#28) 2026-02-22 19:26:45 -08:00
draft.adjust-time-bank.ts Add TypeScript types and improve draft validation (#28) 2026-02-22 19:26:45 -08:00
draft.force-autopick.ts Add TypeScript types and improve draft validation (#28) 2026-02-22 19:26:45 -08:00
draft.force-manual-pick.ts Add TypeScript types and improve draft validation (#28) 2026-02-22 19:26:45 -08:00
draft.make-pick.ts Add TypeScript types and improve draft validation (#28) 2026-02-22 19:26:45 -08:00
draft.pause.ts Add TypeScript types and improve draft validation (#28) 2026-02-22 19:26:45 -08:00
draft.replace-pick.ts Add TypeScript types and improve draft validation (#28) 2026-02-22 19:26:45 -08:00
draft.resume.ts Add TypeScript types and improve draft validation (#28) 2026-02-22 19:26:45 -08:00
draft.rollback.ts Add TypeScript types and improve draft validation (#28) 2026-02-22 19:26:45 -08:00
draft.start.ts Add TypeScript types and improve draft validation (#28) 2026-02-22 19:26:45 -08:00
queue.add.ts Add TypeScript types and improve draft validation (#28) 2026-02-22 19:26:45 -08:00
queue.clear.ts Add TypeScript types and improve draft validation (#28) 2026-02-22 19:26:45 -08:00
queue.remove.ts Add TypeScript types and improve draft validation (#28) 2026-02-22 19:26:45 -08:00
queue.reorder.ts Add TypeScript types and improve draft validation (#28) 2026-02-22 19:26:45 -08:00