blog2025-04-23-upgrading.md9 matches
8Today, weβre unifying our two primitives β *vals* and *projects* β into a single primitive: the **val**, with the best features of both.
910Historically, vals have been simple and lightweight, but limited to a single file. This upgrade will preserve the elegant spirit of our platform while supporting more complex code and collaborative workflows. This upgrade will help you create bigger things on Val Town β APIs, internal tools, fullstack apps, blogs ([like this one](https://www.val.town/x/valdottown/blog)), and much more β without sacrificing the simplicity you've always loved about vals.
1112*Legacy vals* will temporarily become *projects* during this migration. Post-migration, the concept of *projects* will disappear entirely β leaving only upgraded *vals*. In short: *legacy vals* β *projects* β *vals*.
16For most users, no upgrade action is required. Weβll auto-migrate your vals next week. All existing HTTP endpoints, crons, email handlers, and custom domains will be preserved.
1718For those with mission-critical vals or who use our API to edit or create vals, you can start upgrading your legacy vals today and integrating with our updated API.
1920- **April 23, 2025** β Announcement of changes & API deprecations.
21- **April 30, 2025** β All remaining *legacy vals* auto-upgraded. Deprecated API routes become read-only.
22- **May 1, 2025** β The term *projects* will no longer exist β everything will simply be a *val*.
2335[See more details in our docs.](https://docs.val.town/upgrading/legacy-vals)
3637## API Changes
3839Today, we're introducing the following API routes:
4041```bash
73```
7475View our [updated API reference here](https://docs.val.town/openapi).
7677All `v1/vals` API routes become read-only on **April 30, 2025**. If you rely on *writing* to those routes, please upgrade to our new `v2/vals` API. All deprecated API routes will continue serving historical legacy val data.
7879### SDK changes
85861. Upgrade your mission-critical vals early.
872. Update your Val Town API & SDK usage to `/v2` routes.
883. All remaining legacy vals migrate on **April 30, 2025**.
894. Migration completes on **May 1, 2025**.
blog2025-04-08-migration.md1 match
83We didn't. We left them where they are, and proxy to them.
8485Writing 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:
8687```ts
14app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
1516// Add your API routes here
17// app.get("/api/data", c => c.json({ hello: "world" }));
1819// Unwrap and rethrow Hono errors as the original error
reactHonoStarterindex.ts2 matches
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
1314// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
1617// Unwrap and rethrow Hono errors as the original error
French_Bulldogmain.tsx1 match
79// This is a no-op if nothing's changed
80if (!isEndpointSet) {
81await bot.api.setWebhook(req.url, {
82secret_token: SECRET_TOKEN,
83});
79// This is a no-op if nothing's changed
80if (!isEndpointSet) {
81await bot.api.setWebhook(req.url, {
82secret_token: SECRET_TOKEN,
83});
RedditScrappermain.js2 matches
2import moment from "npm:moment-timezone";
34// Reddit API credentials
5const clientId = "-ngsEqbToTa_FlVv-Uy28g";
6const clientSecret = "iE3aFgBYsZvCZmyLWOlAhI9pFAQ2-g";
9async function getAccessToken() {
10const response = await axios.post(
11"https://www.reddit.com/api/v1/access_token",
12new URLSearchParams({
13grant_type: "client_credentials", // Use client credentials flow
8## Hono
910This app uses [Hono](https://hono.dev/) as the API framework. You can think of Hono as a replacement for [ExpressJS](https://expressjs.com/) that works in serverless environments like Val Town or Cloudflare Workers. If you come from Python or Ruby, Hono is also a lot like [Flask](https://github.com/pallets/flask) or [Sinatra](https://github.com/sinatra/sinatra), respectively.
1112## Serving assets to the frontend
20### `index.html`
2122The most complicated part of this backend API is serving index.html. In this app (like most apps) we serve it at the root, ie `GET /`.
2324We *bootstrap* `index.html` with some initial data from the server, so that it gets dynamically injected JSON data without having to make another round-trip request to the server to get that data on the frontend. This is a common pattern for client-side rendered apps.
2526## CRUD API Routes
2728This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
2930## Errors
3132Hono and other API frameworks have a habit of swallowing up Errors. We turn off this default behavior by re-throwing errors, because we think most of the time you'll want to see the full stack trace instead of merely "Internal Server Error". You can customize how you want errors to appear.
887<meta name="viewport" content="width=device-width, initial-scale=1.0">
888<title>Character Creator - Select Race (Holographic Cards)</title>
889<link rel="preconnect" href="https://fonts.googleapis.com">
890<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
891<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700;900&family=Orbitron:wght@700&display=swap" rel="stylesheet">
892<style>${css}</style>
893</head>
ArabicChef_Botmain.tsx1 match
79// This is a no-op if nothing's changed
80if (!isEndpointSet) {
81await bot.api.setWebhook(req.url, {
82secret_token: SECRET_TOKEN,
83});