• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
pchinjr

pchinjr

devfest26-raffle

Public
Like
devfest26-raffle
Home
Code
7
.vtignore
AGENTS.md
DOCS.md
README.md
deno.json
H
main.http.ts
server.ts
Environment variables
1
Branches
1
Pull requests
Remixes
History
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.
Sign up now
Code
/
DOCS.md
Code
/
DOCS.md
Search
…
Viewing readonly version of main branch: v65
View latest version
DOCS.md

Raffle Docs

1. System Overview

This val is a single HTTP app (main.http.ts) built with Hono. It serves both UI and API routes.

There are three UX surfaces:

  • Public page (/) for entry creation
  • Admin home (/admin) for live operations (draw/reset)
  • Admin management (/admin/manage) for prize pool CRUD and deeper inspection

2. Data Model

Prize

  • id: string stable identifier
  • name: string display name

Entry

  • id: string
  • name: string
  • email: string
  • createdAt: ISO string
  • prizeIds: string[] selected prize IDs

WinnerRecord

  • prizeId: string
  • prize: string denormalized name
  • entry: Entry
  • announcedAt: ISO string

Winners

  • Record<string, WinnerRecord> keyed by prizeId

3. Persistence Strategy

Blob keys:

  • devfest26_raffle_prizes_v1
  • devfest26_raffle_entries_v2
  • devfest26_raffle_winners_v2

In-memory mirrors are maintained:

  • memoryPrizes
  • memoryEntries
  • memoryWinners

Reason: local/dev resilience and graceful behavior if blob reads fail.

4. Compatibility Rules

Normalization functions (normalizeEntry, normalizeWinners) handle older payload shapes:

  • Legacy prizeIndexes converted to current prizeIds
  • Missing prize selection defaults to "all current prizes"
  • Winner records keyed/indexed by older formats are mapped to current prizeId

5. Core Business Rules

  • One entry per email
  • Entrants may select one or more prizes
  • One winner per prize
  • Entrant can win at most one prize total
  • Admin key required for all admin pages/APIs

6. Admin Views

/admin

  • Fast event operations
  • Winner draw controls
  • Submissions overview
  • Reset action
  • Link to management view

/admin/manage

  • Add prize
  • Rename prize
  • Remove prize (two-click confirmation)
  • Submissions + winners visibility
  • Prize Pool section intentionally placed lower (less frequent action)

7. API Reference

Public

POST /api/entries

  • Body: { name: string, email: string, prizeIds: string[] }
  • 201 on success, errors on validation/duplicates

Admin

All admin routes require ?key=<ADMIN_KEY>.

GET /api/admin/state

  • Returns { entriesCount, winners, prizes }

POST /api/admin/draw

  • Body: { prizeId: string }
  • Draws winner among eligible entrants for that prize

POST /api/admin/reset

  • Clears entries + winners (prizes remain)

POST /api/admin/prizes

  • Body: { name: string }
  • Adds prize

PATCH /api/admin/prizes/:prizeId

  • Body: { name: string }
  • Renames prize

DELETE /api/admin/prizes/:prizeId

  • Removes prize and prunes related entry/winner references

8. Route/Handler Mapping

  • renderHome -> GET /
  • renderAdminHome -> GET /admin
  • renderAdmin -> GET /admin/manage
  • handleCreateEntry -> POST /api/entries
  • handleDrawWinner -> POST /api/admin/draw
  • handleResetRaffle -> POST /api/admin/reset
  • handleAddPrize -> POST /api/admin/prizes
  • handleRenamePrize -> PATCH /api/admin/prizes/:prizeId
  • handleRemovePrize -> DELETE /api/admin/prizes/:prizeId

9. Operational Notes

  • If UI seems stale, hard refresh browser.
  • If admin pages return 401, key mismatch.
  • If a fetch tool URL encodes ?key=..., route may look like 404 even when real route works in browser.
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.