I got a bit sidetracked this afternoon, I wondered how hard it would be to generate a typed API client based on my schema structure. Turns out it is possible!
First you define your route using a defineRoute primative with a secret _Response structure export
When generated it creates a fetch-based ApiClient for that module, even converting URLPattern parameters to method params (not shown) like so:
Which uses a generated namespace type which is created using the secret _Response export. It nicely compacts the union type too
Then you get a simple to import and use TypeScript client.
I don't think I'll be using it in production any time soon, but it was a fun exploration
I originally tried to do it purely on TypeScript types but my god the API to parse and navigate them is horrendous