Public
Like
4
Electric
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: v41View latest version
A minimalist file storage API built with Hono and Val Town's blob storage. It also serves HTML files as a static website.
API endpoints require bearer token authentication. Set the MASTER_BEARER
environment variable in your Val Town settings.
Include the token in your API requests:
Authorization: Bearer your-secret-token
Note: Static site content (HTML, CSS, JS, etc.) is served without authentication.
POST /route
Form Parameters:
file: The file to uploadfilename: The name to save the file as
Example:
curl -X POST https://your-val.web.val.run/route \ -H "Authorization: Bearer your-secret-token" \ -F "file=@/path/to/your/file.pdf" \ -F "filename=document.pdf"
GET /route?filename=your-filename
Query Parameters:
filename: The name of the file to retrieve
Example:
curl -X GET "https://your-val.web.val.run/route?filename=document.pdf" \ -H "Authorization: Bearer your-secret-token"
GET /route
Example:
curl -X GET https://your-val.web.val.run/route \ -H "Authorization: Bearer your-secret-token"
DELETE /
Example:
curl -X DELETE https://your-val.web.val.run/ \ -H "Authorization: Bearer your-secret-token"
All files stored in the blob storage are also served as a static website. HTML files are served with the correct content type.
Simply navigate to the URL path matching your file:
https://your-val.web.val.run/your-file.html
- The root URL (
/) servesindex.htmlif it exists - URLs without file extensions will try to serve an
index.htmlfile in that path
For example:
/aboutwill try to serve/about/index.html/blog/post-1will try to serve/blog/post-1/index.html
All files are stored in Val Town's blob storage with the prefix vt-docs/ to
ensure safety and organization.
- The DELETE endpoint only removes files with the
vt-docs/prefix - Authentication is required for all API operations
- Static site content is served without authentication for public access
- Input validation using Zod ensures data integrity
- Error handling provides clear feedback