Public
Like
iClickWolf
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: v171View latest version
This app is a port of the iClickWolf Next.js application to Val Town, using SQLite for database storage.
-
Backend:
/backend/index.ts
- The main HTTP server that serves the frontend and API endpoints/backend/database/
- Contains SQLite database setup and queries/backend/routes/
- API routes for checkout, webhook, and items
-
Frontend:
/frontend/index.html
- The main HTML entry point/frontend/index.tsx
- The React entry point/frontend/components/
- React components for the application
- iClicker preordering system
- Stripe integration for payments
- Email notifications for order confirmations
- SQLite database for storing items and preorders
The following environment variables are required:
STRIPE_SECRET
- Stripe API secret keySTRIPE_PUBLIC
- Stripe publishable key (for frontend)STRIPE_WEBHOOK_SECRET
- Secret for verifying Stripe webhook eventsVAL_EMAIL_KEY
- API key for the email sending service
The application includes robust error handling:
- If Stripe is not configured (missing API keys), appropriate error messages are shown
- If the database fails to load items, default values are used as a fallback
- All API errors are properly logged and user-friendly messages are displayed
- Form validation prevents submission of invalid data
The application uses Val Town's SQLite database with the following tables:
iclickwolf_items_v1
- Stores product informationiclickwolf_preorders_v1
- Stores customer preorder information
POST /api/checkout
- Creates a Stripe checkout session and preorderPOST /api/webhook
- Handles Stripe webhook eventsGET /api/items
- Returns the first item (iClicker)