Todo
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v7View latest version
Minimal Val Town todo template using a TypeScript Hono backend and a static frontend.
deno run --allow-net --allow-read --allow-write backend/index.ts
The server listens on http://localhost:8000. Navigate there to see the todo UI. SQLite data is stored in the generated todo_app_entries_v1 table within the in-memory database file managed by the Val Town runtime.
| Method | Path | Description |
|---|---|---|
GET | /api/todos | Fetch all todos, sorted newest first. |
POST | /api/todos | Create a todo. JSON body: { "text": "Write tests" }. |
PATCH | /api/todos/:id | Update done/text flag. JSON body can include done and/or text. |
DELETE | /api/todos/:id | Remove the todo. |
All responses are JSON. Error responses include { "error": "message" }.
frontend/index.htmlbootstraps a Tailwind-styled UI.- Inline module script calls
/api/todosto load, add, toggle, and delete tasks. - The view-source link is populated from the backend to comply with Val Town requirements.
Use curl or any HTTP client to exercise the API.
# create curl -X POST -H "Content-Type: application/json" -d '{"text":"Inspect Val Town"}' http://localhost:8000/api/todos # toggle done curl -X PATCH -H "Content-Type: application/json" -d '{"done":true}' http://localhost:8000/api/todos/1 # delete curl -X DELETE http://localhost:8000/api/todos/1
Observe logs and UI refreshing automatically after each action.