llm-tips
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: v293View latest version
Kuadratic is a Val Town voting widget that exports embeddable HTML components backed by SQLite, with configurable limits for fair participation.
- Multiple Options: Support for multi-choice polls
- Persistent Storage: Votes saved in Val Town's SQLite DB
- Vote Limits: Configurable per-user and global caps
- Embeddable: Self-contained HTML with CSS/JS
- Live Feedback: UI updates after voting, with validations
import { createVotingWidget, initializeOptions } from "./index.ts";
const config = {
pollId: "my-poll-2024",
maxTotalVotes: 1000,
maxVotesPerUser: 3,
options: [
{ id: "option1", title: "Option 1", description: "First choice" },
{ id: "option2", title: "Option 2", description: "Second choice" },
{ id: "option3", title: "Option 3" }
]
};
await initializeOptions(config);
const widgetHTML = createVotingWidget(config);
## API
* POST /api/vote: Submit vote
* GET /api/results/:pollId: Retrieve current results
### Payload example
{
"pollId": "my-poll-2024",
"optionId": "option1",
"voterId": "unique-voter-id",
"maxTotalVotes": 1000,
"maxVotesPerUser": 3
}
## Vote Limiting
Global Limit: maxTotalVotes restricts total submissions per poll
Per-User Limit: maxVotesPerUser enforced via voterId
## Integration
Embed the generated HTML on any webpage
Automatically loads current vote counts and handles updates
Enforces all vote limits with appropriate messaging
Kuadratic ensures secure, easy-to-integrate voting with real-time behavior and robust guardrails for fair use.