Public
Like
untitled-1496
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.
index.ts
https://ikeali--909566ce3fa011f0970476b3cceeab13.web.val.run
A comprehensive online voting platform built with TypeScript, Hono, React, and SQLite.
- π³οΈ Poll Creation: Create polls with multiple options
- π₯ User Authentication: Secure user registration and login
- π Real-time Results: Live vote counting and visualization
- π Vote Security: One vote per user per poll
- π± Responsive Design: Works on desktop and mobile
- π Admin Dashboard: Manage polls and users
βββ backend/
β βββ database/
β β βββ migrations.ts # Database schema setup
β β βββ queries.ts # Database query functions
β βββ routes/
β β βββ auth.ts # Authentication routes
β β βββ polls.ts # Poll management routes
β β βββ votes.ts # Voting routes
β βββ index.ts # Main server entry point
βββ frontend/
β βββ components/
β β βββ App.tsx # Main application component
β β βββ Auth.tsx # Login/Register forms
β β βββ PollList.tsx # Display all polls
β β βββ PollDetail.tsx # Individual poll view
β β βββ CreatePoll.tsx # Poll creation form
β β βββ Results.tsx # Vote results visualization
β βββ index.html # Main HTML template
β βββ index.tsx # Frontend entry point
βββ shared/
βββ types.ts # Shared TypeScript interfaces
POST /api/auth/register
- User registrationPOST /api/auth/login
- User loginGET /api/auth/me
- Get current user
GET /api/polls
- List all pollsPOST /api/polls
- Create new pollGET /api/polls/:id
- Get specific pollDELETE /api/polls/:id
- Delete poll (admin only)
POST /api/votes
- Cast a voteGET /api/polls/:id/results
- Get poll results
- Set up the database by running the migrations
- Start the server with the HTTP trigger
- Access the application at the provided URL
- Register a new account or login
- Create polls and start voting!
- Password hashing with bcrypt
- JWT-based authentication
- Vote uniqueness enforcement
- Input validation and sanitization