my-first-val1
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.
02_http.tsx
https://ikeali--7e2b8b5b9689454c906d7ce5a4174bd2.web.val.run
A comprehensive online voting platform built with Val Town, featuring secure authentication, poll management, and real-time results.
- User Authentication: Secure login/registration system
- Poll Management: Create, edit, and manage voting polls
- Voting Interface: Clean, intuitive voting experience
- Real-time Results: Live vote counting and result display
- Admin Dashboard: Manage polls and view analytics
- Security: One vote per user per poll enforcement
βββ backend/
β βββ database/
β β βββ migrations.ts # Database schema setup
β β βββ queries.ts # Database query functions
β βββ routes/
β β βββ auth.ts # Authentication endpoints
β β βββ polls.ts # Poll management endpoints
β β βββ votes.ts # Voting endpoints
β β βββ static.ts # Static file serving
β βββ index.ts # Main Hono app entry point
βββ frontend/
β βββ components/
β β βββ App.tsx # Main React app
β β βββ Login.tsx # Login/register component
β β βββ PollList.tsx # List of available polls
β β βββ PollDetail.tsx # Individual poll voting interface
β β βββ CreatePoll.tsx # Poll creation form
β β βββ Results.tsx # Results display component
β βββ index.html # Main HTML template
β βββ index.tsx # Frontend entry point
β βββ style.css # Custom styles
βββ shared/
βββ types.ts # Shared TypeScript types
βββ utils.ts # Shared utility functions
- id (PRIMARY KEY)
- username (UNIQUE)
- email (UNIQUE)
- password_hash
- is_admin
- created_at
- id (PRIMARY KEY)
- title
- description
- creator_id (FOREIGN KEY)
- start_date
- end_date
- is_active
- created_at
- id (PRIMARY KEY)
- poll_id (FOREIGN KEY)
- option_text
- vote_count
- id (PRIMARY KEY)
- poll_id (FOREIGN KEY)
- user_id (FOREIGN KEY)
- option_id (FOREIGN KEY)
- voted_at
POST /api/auth/register- User registrationPOST /api/auth/login- User loginPOST /api/auth/logout- User logoutGET /api/auth/me- Get current user
GET /api/polls- List all active pollsGET /api/polls/:id- Get specific poll detailsPOST /api/polls- Create new poll (authenticated)PUT /api/polls/:id- Update poll (creator/admin only)DELETE /api/polls/:id- Delete poll (creator/admin only)
POST /api/votes- Cast a voteGET /api/polls/:id/results- Get poll results
- The system uses SQLite for data storage
- Authentication uses session-based cookies
- The frontend is a React SPA with TailwindCSS
- Real-time updates use polling (can be upgraded to WebSockets)
- Password hashing with bcrypt
- Session-based authentication
- CSRF protection
- One vote per user per poll enforcement
- Input validation and sanitization