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: v154View latest version
- Skips all filesystem operations
- Automatically sets
APP_ENV=prodwhen on Val Town - Returns immediately without trying to read
.env.dev
- Console-only logging (no file handlers)
- Removes all
Deno.mkdirand file write operations - Maintains same API for compatibility
- Preserves colored console output and emojis
- Uses embedded OpenAPI spec instead of reading from file
- Extends original loader class to override
loadSpecmethod - Maintains all other functionality
- Contains the entire OpenAPI specification as a JavaScript object
- Eliminates need for
openapi.jsonfile
- Uses Val Town compatible imports
- Otherwise identical to original
- Automatically detects Val Town environment
- Loads appropriate modules based on environment
- Provides unified interface for both environments
- Single entry point that works everywhere
- Uses module selector for environment detection
- Exports appropriately for Val Town or starts server locally
// Option 1: Use the universal main
import "./main-universal.ts";
// Option 2: Use Val Town specific files
import "./main-valtown.ts";
# Continue using original main.ts deno run --allow-all main.ts # Or use universal main deno run --allow-all main-universal.ts
Set these in Val Town's environment settings:
PAYMENT_USERNAMEPAYMENT_PASSWORDTURNSTILE_SECRET_KEYALLOWED_ORIGINS(comma-separated list)ADMIN_API_KEYSESSION_SECRETWEBHOOK_SECRETVALTOWN_TOKEN
| Feature | Local Development | Val Town |
|---|---|---|
| Config Files | Reads .env.dev | Uses Val Town env vars |
| Logging | File + Console | Console only |
| OpenAPI Spec | Reads openapi.json | Embedded in code |
| File Access | Full filesystem | No filesystem access |
After deployment, test these endpoints:
GET /- Basic health checkGET /health- Health statusGET /api/v1/tours- API functionalityGET /openapi.json- OpenAPI spec serving
All handlers, middleware, and services work without modification. The compatibility layer handles all environment differences transparently.