83We didn't. We left them where they are, and proxy to them.
84
85Writing a proxy in Val Town (or any functions platform with the ['fetch handler' interface](https://blog.val.town/blog/the-api-we-forgot-to-name/)) is a delight:
86
87```ts
89export async function proxy(req: Request): Promise<Response> {
90 const url = new URL(req.url);
91 return fetch(OLD_BLOG_HOST + url.pathname + url.search, {
92 method: req.method,
93 headers: req.headers,
23});
24
25// HTTP vals expect an exported "fetch handler"
26// This is how you "run the server" in Val Town with Hono
27export default app.fetch;
21});
22
23// HTTP vals expect an exported "fetch handler"
24// This is how you "run the server" in Val Town with Hono
25export default app.fetch;
49});
50
51// Fetch all subreddit data
52const results = {};
53async function fetchSubredditData() {
54 const accessToken = await getAccessToken(); // Get access token
55 console.log(accessToken);
80
81(async function main() {
82 await fetchSubredditData();
83
84 const row = [timestamp, ...subredditMap.map(({ subreddit }) => results[subreddit])].join(",") + "\n";
85
86 console.log("✅ Fetched data:");
87 console.log(row);
88})();
11
12 try {
13 const response = await fetch("/messages", {
14 method: "POST",
15 headers: { "Content-Type": "application/json" },
175 return generatedData;
176 } catch (error) {
177 console.error("Error fetching or processing data from OpenAI:", error);
178 console.warn("Using fallback race data due to the error.");
179 return fallbackRaceData.slice(0, numToRequest).map(race => ({
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({
108
109 try {
110 const response = await fetch('/register-object', {
111 method: 'POST',
112 body: formData
137
138 try {
139 const response = await fetch('/notify-object', {
140 method: 'POST',
141 headers: {
181
182 try {
183 const response = await fetch("/", {
184 method: "POST",
185 body: JSON.stringify({
240 const currentTime = Date.now();
241 if (!dictionaryCache.length || (currentTime - dictionaryCacheTimestamp > CACHE_TTL)) {
242 const response = await fetch(
243 "https://gist.githubusercontent.com/brydenfogelman/b35955805e7dca0fe57f6aa25950231c/raw/4233a5653536fe4b6984702bb9273c967c35ef91/dictionary.json",
244 );
245
246 if (!response.ok) {
247 throw new Error(`Failed to fetch dictionary: ${response.status}`);
248 }
249
295 const currentTime = Date.now();
296 if (!boardsCache.length || (currentTime - boardsCacheTimestamp > CACHE_TTL)) {
297 const response = await fetch(
298 "https://gist.githubusercontent.com/brydenfogelman/517fb8666c9c144ab83873d83d44c56f/raw/4ac1123fb72818acc895e3f25e6b9a637649d00b/boards.json",
299 );
300
301 if (!response.ok) {
302 throw new Error(`Failed to fetch boards: ${response.status}`);
303 }
304