34const CACHE_BUCKET_PREFIX = "quarterpriceauctionscanner";
5const AUCTIONS_CACHE_KEY = CACHE_BUCKET_PREFIX + "/qpaapi/auctions_data";
67export default async function updateAuctionCache() {
40const fetchCachedData = async () => {
41try {
42const response = await fetch("/api/cached-data");
43const data = await response.json();
44if (data.success) {
196// Server-side handler
197async function server(request: Request): Promise<Response> {
198// Handle API requests
199if (request.url.endsWith("/api/cached-data")) {
200const { blob } = await import("https://esm.town/v/std/blob?v=13");
201
blogget-old-posts.ts25 matches
19export const oldPosts: BlogPost[] = [
20{
21"title": "Solving the internal / external API riddle",
22"slug": "api-conundrum",
23"link": "/blog/api-conundrum",
24"description": "Figuring out how to provide an API that's usable by everyone and fast for us to iterate on",
25"pubDate": "Thu, 27 Mar 2025 00:00:00 GMT",
26"author": "Tom MacWright",
27},
28{
29"title": "API Tokens Scopes",
30"slug": "api-token-scopes",
31"link": "/blog/api-token-scopes",
32"description": "Improving security with granular control over permissions",
33"pubDate": "Fri, 01 Nov 2024 00:00:00 GMT",
59},
60{
61"title": "Expanding the Vals API - RFC",
62"slug": "expanding-the-vals-api-rfc",
63"link": "/blog/expanding-the-vals-api-rfc",
64"description": "Our REST API lets you do a lot - and soon it will enable more",
65"pubDate": "Fri, 30 Jun 2023 00:00:00 GMT",
66"author": "André Terron",
133},
134{
135"title": "The perks of a good OpenAPI spec",
136"slug": "openapi",
137"link": "/blog/openapi",
138"description": "Taking advantage of our typed REST API to build a platform around\nVal Town.",
139"pubDate": "Thu, 25 Jul 2024 00:00:00 GMT",
140"author": "Tom MacWright",
262},
263{
264"title": "The API we forgot to name",
265"slug": "the-api-we-forgot-to-name",
266"link": "/blog/the-api-we-forgot-to-name",
267"description": "An API that takes a Request and returns a Response - what was that, again?",
268"pubDate": "Thu, 19 Oct 2023 00:00:00 GMT",
269"author": "Steve Krouse",
286},
287{
288"title": "Deprecating the Run API",
289"slug": "deprecating-the-run-api",
290"link": "/blog/deprecating-the-run-api",
291"description": "Not every function should be an API",
292"pubDate": "Wed, 07 Feb 2024 00:00:00 GMT",
293"author": "André Terron",
321"slug": "val-town-newsletter-1",
322"link": "/blog/val-town-newsletter-1",
323"description": "Programmatic notifications, Hacker News API, and more.",
324"pubDate": "Wed, 04 Jan 2023 00:00:00 GMT",
325"author": "Steve Krouse",
450"slug": "val-town-newsletter-22",
451"link": "/blog/val-town-newsletter-22",
452"description": "Townie upgrades, Scoped API permissions, Fal partnership",
453"pubDate": "Mon, 02 Dec 2024 00:00:00 GMT",
454"author": "Steve Krouse",
3- [ ] Make it faster
4- [ ] Add cache headers for Cloudflare.
5- [ ] Is there a way to bust the cache manually via api can we call that everytime we save a new version?
6- [ ] Add og: content for new posts hosted here (old posts will have it still)
7- [ ] Deploy it to blog.val.town!
blog-vt2get-old-posts.ts25 matches
19export const oldPosts: BlogPost[] = [
20{
21"title": "Solving the internal / external API riddle",
22"slug": "api-conundrum",
23"link": "/blog/api-conundrum",
24"description": "Figuring out how to provide an API that's usable by everyone and fast for us to iterate on",
25"pubDate": "Thu, 27 Mar 2025 00:00:00 GMT",
26"author": "Tom MacWright",
27},
28{
29"title": "API Tokens Scopes",
30"slug": "api-token-scopes",
31"link": "/blog/api-token-scopes",
32"description": "Improving security with granular control over permissions",
33"pubDate": "Fri, 01 Nov 2024 00:00:00 GMT",
59},
60{
61"title": "Expanding the Vals API - RFC",
62"slug": "expanding-the-vals-api-rfc",
63"link": "/blog/expanding-the-vals-api-rfc",
64"description": "Our REST API lets you do a lot - and soon it will enable more",
65"pubDate": "Fri, 30 Jun 2023 00:00:00 GMT",
66"author": "André Terron",
133},
134{
135"title": "The perks of a good OpenAPI spec",
136"slug": "openapi",
137"link": "/blog/openapi",
138"description": "Taking advantage of our typed REST API to build a platform around\nVal Town.",
139"pubDate": "Thu, 25 Jul 2024 00:00:00 GMT",
140"author": "Tom MacWright",
262},
263{
264"title": "The API we forgot to name",
265"slug": "the-api-we-forgot-to-name",
266"link": "/blog/the-api-we-forgot-to-name",
267"description": "An API that takes a Request and returns a Response - what was that, again?",
268"pubDate": "Thu, 19 Oct 2023 00:00:00 GMT",
269"author": "Steve Krouse",
286},
287{
288"title": "Deprecating the Run API",
289"slug": "deprecating-the-run-api",
290"link": "/blog/deprecating-the-run-api",
291"description": "Not every function should be an API",
292"pubDate": "Wed, 07 Feb 2024 00:00:00 GMT",
293"author": "André Terron",
321"slug": "val-town-newsletter-1",
322"link": "/blog/val-town-newsletter-1",
323"description": "Programmatic notifications, Hacker News API, and more.",
324"pubDate": "Wed, 04 Jan 2023 00:00:00 GMT",
325"author": "Steve Krouse",
450"slug": "val-town-newsletter-22",
451"link": "/blog/val-town-newsletter-22",
452"description": "Townie upgrades, Scoped API permissions, Fal partnership",
453"pubDate": "Mon, 02 Dec 2024 00:00:00 GMT",
454"author": "Steve Krouse",
frankIndigoSwordtailmain.tsx1 match
4async function fetchRandomJoke() {
5const response = await fetch(
6"https://official-joke-api.appspot.com/random_joke",
7);
8return response.json();
spagindex.html3 matches
230uploadButton.disabled = true;
231uploadButton.textContent = "Uploading...";
232const response = await fetch("/api/upload", {
233method: "POST",
234body,
251252async function fetchUploads() {
253const response = await fetch("/api/list");
254const data = await response.json();
255return data.rows;
395deleteButton.textContent = "Deleting...";
396const response = await fetch(
397`/api/delete`,
398{
399method: "POST",
1import { useState, useEffect } from "https://esm.sh/react@18.2.0?dev";
2import { fetchProjectFiles } from "../utils/api.ts";
34interface UseProjectFilesProps {
Open-ToownieuseChatLogic.ts4 matches
6project: any;
7branchId: string | undefined;
8anthropicApiKey: string;
9bearerToken: string;
10selectedFiles: string[];
16project,
17branchId,
18anthropicApiKey,
19bearerToken,
20selectedFiles,
35status,
36} = useChat({
37api: "/api/send-message",
38body: {
39project,
40branchId,
41anthropicApiKey,
42selectedFiles,
43images: images
Open-Toowniesystem_prompt.txt7 matches
98- For AI-generated images, use: `https://maxm-imggenurl.web.val.run/the-description-of-your-image`
99- **Storage:** DO NOT use the Deno KV module for storage
100- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
101- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
102- **View Source:** Add a view source link with `import.meta.url.replace("esm.town", "val.town")` and include `target="_top"` attribute
103- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
104- **Error Handling:** Only use try...catch when there's a clear local resolution; avoid catches that merely log or return 500s - let errors bubble up with full context
105- **Environment Variables:** Use `Deno.env.get('keyname')` and minimize their use - prefer APIs without keys
106- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
107- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
188189### Backend (Hono) Best Practices
190- Hono is the recommended API framework (similar to Express, Flask, or Sinatra)
191- Main entry point should be `backend/index.ts`
192- **Static asset serving:** Use the utility functions to read and serve project files:
209});
210```
211- Create RESTful API routes for CRUD operations
212- Be careful with error handling as Hono tends to swallow errors
213- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
226- Use React 18.2.0 consistently in all imports and the `@jsxImportSource` pragma
227- Follow the React component pattern from the example project
228- Handle API calls properly with proper error catching
229230### Database Patterns
257- For files in the project, use `readFile` helpers
2582595. **API Design:**
260- `fetch` handler is the entry point for HTTP vals
261- Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`