Skip to content

Migrate admin routes from Hono to TanStack Start #485

@InfinityBowman

Description

@InfinityBowman

Context

Tier 3 of the Hono → TanStack Start consolidation. Blocked on / runs alongside #484 (billing). Migration recipe: `packages/docs/audits/hono-to-tanstack-migration.md`.

Scope

Files in `packages/workers/src/routes/admin/`, recommended order smallest-first:

  • `index.ts` (34 lines — router wiring)
  • `orgs.ts` (393 lines)
  • `storage.ts` (525 lines)
  • `stats.ts` (665 lines)
  • `projects.ts` (772 lines)
  • `billing-observability.ts` (788 lines)
  • `stripe-tools.ts` (808 lines)
  • `database.ts` (997 lines)
  • `users.ts` (1,092 lines)
  • `billing.ts` (1,195 lines)

~7,200 lines total across 10 files.

Per-file recipe

  1. Create TanStack file route(s) under `packages/web/src/routes/api/admin/`
  2. These routes need an admin-role guard. If not already in `packages/web/src/server/guards/`, add one (probably `requireAdmin(request, env)` checking `user.role === 'admin'`)
  3. Port tests into co-located `tests/*.server.test.ts`
  4. Strip the Hono route to an empty stub
  5. Delete the corresponding Hono test file
  6. Run both test suites and typechecks

Notes

  • Most admin routes are read-only dashboards → faster per-line than billing
  • Several files are large because they bundle many endpoints; consider splitting one Hono file into multiple TanStack files along endpoint boundaries
  • `billing.ts` and `billing-observability.ts` may share Stripe helpers with the billing webhook tree — don't strip those helpers

Suggested branch

`migrate-admin-routes`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions