Cloudflare Worker Site + HTMLRewriter structure

Hello, I’m building a Cloudflare Worker Site with Vue.js. I would like to use HTMLRewriter to handle all API requests. For instance, if you visit{gameid} then the API call to fetch the {gameid} data will happen using the HTMLRewriter (either by making an external API request or using Cloudflare Workers KV) which would result in the API call being hidden from the user.

However, I’m not sure how it would be best to structure such a project. Imagine it’s a big site where you had to call many different API endpoints based on the route, e.g.{gameid}/guide/{guideid}{gameid}/article/{articleid}{publisherid}{userid}, etc. you get the point.

Where should I make these API calls that would be using HTMLRewriter to insert the data into HTML, and how can I properly structure it so I don’t end up with writing a 1000+ line file? I can’t seem to find any documentation, or any projects on GitHub, that does or addresses this use case (large Cloudflare Worker Site with HTMLRewriter inserting all API responses into the HTML).