Unlisted
Like
ZenServer
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: v517View latest version
Automatically sync your local openapi.json file to Val Town blob storage.
- Go to https://val.town/settings/api
- Create a new API token
- Copy the token value
Windows (PowerShell):
$env:VALTOWN_API_TOKEN = "your_token_here"
Windows (Command Prompt):
set VALTOWN_API_TOKEN=your_token_here
Permanent (Windows):
[Environment]::SetEnvironmentVariable("VALTOWN_API_TOKEN", "your_token_here", "User")
cd ZenServer\scripts sync-openapi.bat
cd ZenServer\scripts .\sync-openapi-to-valtown.ps1
cd ZenServer\scripts deno run -A sync-openapi-to-valtown.ts
- Source:
F:\val.town\ZenServer\openapi.json - Destination:
__public/ZPServer/openapi.jsonin Val Town blob storage - Action: Creates or overwrites the blob automatically
- Verification: Reads back the uploaded content to verify success
After upload, your OpenAPI spec will be available at:
https://api.val.town/v1/blob/__public%2FZPServer%2Fopenapi.json
- API token is read from environment variable (not stored in scripts)
- Uses HTTPS for all API calls
- Validates JSON before upload
- Verifies upload integrity
You can modify the file paths by editing the script variables:
PowerShell:
.\sync-openapi-to-valtown.ps1 -LocalFile "C:\custom\path\openapi.json" -BlobKey "custom/key"
Deno:
Edit the constants at the top of sync-openapi-to-valtown.ts
"API token required" error:
- Make sure
VALTOWN_API_TOKENenvironment variable is set - Restart your terminal after setting the variable
"File not found" error:
- Check that
F:\val.town\ZenServer\openapi.jsonexists - Verify the file path in the script matches your setup
"Invalid JSON" error:
- Validate your JSON file with a JSON validator
- Check for syntax errors in the OpenAPI spec
Permission errors:
- Run PowerShell as Administrator if needed
- Check that the file is not locked by another application