Application development
API Migration
Moved an admin API from tRPC to layered REST and checked every endpoint against the old one automatically; the slowest call went from 14 s to 0.9 s.
Backend developer
May–Jun 2026
In numbers
- admin endpoints migrated (out of 551 procedures inventoried)
- 43
- admin endpoints migrated (out of 551 procedures inventoried)
- endpoints returning identical responses
- 90 → 142
- endpoints returning identical responses
- endpoints with mismatches
- 130 → 77
- endpoints with mismatches
- slowest endpoint
- 14 s → 0.9 s
- slowest endpoint
The problem
The apps talked to their backend over tRPC, which ties frontend and backend tightly into one TypeScript project. That gets in the way as soon as you need other clients, like a mobile app or an outside integration. There were 551 procedures to move, and none of them were allowed to change behaviour.
What I did
- 1
Inventory first
I listed every procedure by app, HTTP method and how hard it would be to move.
- 2
Four layers
I moved the admin endpoints to a four-layer REST structure: route (the URL), controller (request and response), service (business logic) and repository (database), all behind an admin permission check.
- 3
Parity tests
A test called each endpoint on both the old and new API with the same request and diffed the responses. I fixed mismatches one by one, and the number of exact matches went up every round: 90, 100, 119, 142.
- 4
The slow one
The endpoint that returns the taxonomy tree was timing out at 14 seconds. After I fixed the query, the full tree (2,745 categories, 10.7 MB) came back in 0.9 seconds.
- 5
Switch the frontend
I moved the admin panel off tRPC onto TanStack Query hooks that call the new REST endpoints.
Result
The admin panel now runs entirely on the new API. Endpoints matching the old behaviour exactly went from 90 to 142, and mismatches dropped from 130 to 77.
What I learned
"It works" isn't good enough in a migration; it has to work the same as before. Without the automated parity test I would have been flying blind.
Stack
- Node.js
- Express
- PostgreSQL
- React
- TanStack Query