Public
Football squares pool game grid
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.
A live NBA squares pool you run from a link. Create a room, share the short URL, friends pick squares from their phones, and winners settle automatically off the live NBA score โ no manual scorekeeping.
- Open the app and create a room โ pick a short slug (e.g.
okc), the team tricodes (away + home), and a stake per square. - Share
your-app-url/okc. Each person enters their name and taps squares to claim them. Tap again to release. - When the board hits 100/100, anyone can Lock + roll numbers โ the row
(away) and column (home) digits are shuffled
0โ9. - During the game, the app polls the public NBA scoreboard. At the end of each quarter it derives the winning square from the last digit of each team's cumulative score and credits the payout share. Q1/Q2/Q3/Final shares are configurable (default 15/25/15/45%).
- Winners show up on a leaderboard with one-tap Venmo / Cash App payment links between players.
Rendering mermaid diagram...
| File | Role |
|---|---|
backend/index.ts | Hono HTTP handler โ REST API + serves the frontend |
backend/nba.ts | NBA scoreboard fetch (cached 20s) + quarter settlement |
backend/store.ts | Blob-backed room storage + number shuffle |
backend/types.ts | Shared types + the avatar color palette |
frontend/index.html | App shell |
frontend/app.js | Vanilla-JS SPA: pick view, live view, leaderboard |
frontend/style.css | Dark, mobile-first styling |
| Method & path | Purpose |
|---|---|
POST /api/create | Create a room { slug, label, home, away, stake } |
GET /api/:slug/state | Room + live score (settles quarters when locked) |
POST /api/:slug/join | Register player / claim squares |
POST /api/:slug/release | Release one of your squares |
POST /api/:slug/lock | Lock board + roll the 0โ9 digits |
POST /api/:slug/reset | Unlock + clear numbers/settlements |
- State lives in blob storage keyed by slug โ no database setup needed.
- Scores come from the public
cdn.nba.comlive scoreboard (no API key). It only contains today's games, so lock a room on game day. - Sync is poll-based (4s) since Val Town doesn't accept inbound WebSockets.
- Money flows are just deep links โ the app never touches funds.