Public
Like
cp-root
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: v114View latest version
A router-based API for scanning and managing Val Town endpoints across all your vals.
- GET
/- API documentation and available endpoints - GET
/health- Health check endpoint - GET
/scan- Optimized endpoint scanner (recommended) - GET
/scan-old- Legacy endpoint scanner with additional debugging info
/scan-vals.tsx- Optimized scanner implementation/old-get_vals_endpoints.tsx- Legacy scanner implementation
- π Scans all your Val Town vals for
endpoints.*files (js, jsx, ts, tsx) - π Tests HTTP endpoints and captures responses
- π Returns structured JSON with endpoint metadata
- β‘ Parallel processing for better performance
- π‘οΈ Error handling and graceful degradation
- π API documentation and health checks
VALTOWN_API_TOKEN- Required for accessing Val Town API
- fetch my vals
- loop through vals
- look at each val's file list to find endpoints.tsx
- refine the filtering (endpoints.js, jsx, ts, tsx)
- read each matching val's endpoints file
- refactor into helper functions for better maintainability
- order functions to make sense
- create router for organized API access
- add health checks and documentation
- format output
- fetch it from cloudflare
- save to db or kv store
- implement cache invalidation
- manual refresh endpoint
The main router provides a clean API interface. Use /scan for the optimized version or /scan-old for the legacy version with additional debugging information.
Example response structure:
{ "count": 2, "vals_with_endpoints": [ { "id": "val-id", "name": "my-val", "author": "username", "url": "https://www.val.town/v/username/my-val", "endpoints_files": [ { "name": "endpoints.tsx", "path": "/endpoints.tsx", "http_url": "https://username--valid.web.val.run", "http_status": 200, "http_response": "..." } ] } ] }