view-9448view-1227.tsx1 match
1import { email } from "https://esm.town/v/std/email";
23export default async function(req: Request): Promise<Response> {
4const xForwardedFor = req.headers.get("X-Forwarded-For") ?? "n/a";
5const trueClientIP = req.headers.get("True-Client-IP") ?? "n/a";
1export default async function (req: Request) {
2const html = `<!DOCTYPE html>
3<html lang="en">
130
131// Update the countdown every 1 second
132const countdownTimer = setInterval(function() {
133// Get current date and time
134const now = new Date().getTime();
1import { readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
23export default async function(req: Request): Promise<Response> {
4const url = new URL(req.url);
5const path = url.pathname;
19
20// Create a new orange element
21function createOrange() {
22const orange = document.createElement('div');
23orange.className = 'orange w-12 h-12 bg-orange-500 rounded-full flex items-center justify-center';
41
42// Add an orange to the basket
43function addOrange() {
44const orange = createOrange();
45orangeBasket.appendChild(orange);
54
55// Start dragging an orange
56function startDrag(e) {
57isDragging = true;
58currentOrange = this;
72
73// Handle touch events for mobile
74function handleTouchStart(e) {
75isDragging = true;
76currentOrange = this;
91
92// Drag the orange
93function drag(e) {
94if (!isDragging) return;
95
103
104// Handle touch move for mobile
105function handleTouchMove(e) {
106if (!isDragging) return;
107
118
119// Drop the orange
120function drop(e) {
121if (!isDragging) return;
122
142
143// Handle touch end for mobile
144function handleTouchEnd(e) {
145if (!isDragging) return;
146
166
167// Squeeze the orange
168function squeezeOrange() {
169// Animate the bear squeezing
170bear.classList.add('squeezing');
234
235// Check for achievements based on juice amount
236function checkAchievements() {
237const achievements = [
238{ threshold: 100, message: "๐ First Cup Filled!" },
250
251// Show achievement notification
252function showAchievement(message) {
253const notification = document.createElement('div');
254notification.className = 'fixed top-4 left-1/2 transform -translate-x-1/2 bg-orange-600 text-white px-4 py-2 rounded-lg shadow-lg z-50';
267
268// Reset the game
269function resetGame() {
270// Clear all oranges
271orangeBasket.innerHTML = '';
town-hallAttendeeForm.tsx2 matches
27}
2829export function AttendeeForm({ onSubmitSuccess, onSubmitError }: AttendeeFormProps) {
30const [formData, setFormData] = useState<FormData>({
31name: "",
108};
109110// Helper function to check if an interest is selected
111const isInterestSelected = (interestLabel: string) => {
112return formData.interests.includes(interestLabel);
26});
2728export function App() {
29const [audio, setAudio] = useLocalStorage("AUDIO", false);
30const user = useUser();
1415// Create the attendees table if it doesn't exist
16async function initializeDatabase() {
17console.log("Initializing database...");
18try {
Townie-02useUser.tsx1 match
3const USER_ENDPOINT = "/api/user";
45export function useUser () {
6const [data, setData] = useState<any>(null);
7const [loading, setLoading] = useState(true);
Townie-02system_prompt.txt12 matches
45- Ask clarifying questions when requirements are ambiguous
6- Provide complete, functional solutions rather than skeleton implementations
7- Test your logic against edge cases before presenting the final solution
8- Ensure all code follows Val Town's specific platform requirements
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
19- Follow modern ES6+ conventions and functional programming practices if possible
2021## Types of triggers
2829```ts
30export default async function (req: Request) {
31return new Response("Hello World");
32}
4041```ts
42export default async function () {
43// Scheduled task code
44}
5253```ts
54export default async function (email: Email) {
55// Process email
56}
60## Val Town Standard Libraries
6162Val Town provides several hosted services and utility functions.
6364### Blob Storage
114```
115116## Val Town Utility Functions
117118Val Town provides several utility functions to help with common project tasks.
119120### Importing Utilities
194โ โโโ database/
195โ โ โโโ migrations.ts # Schema definitions
196โ โ โโโ queries.ts # DB query functions
197โ โ โโโ README.md
198โ โโโ routes/ # Route modules
213โโโ shared/
214โโโ README.md
215โโโ utils.ts # Shared types and functions
216```
217221- Main entry point should be `backend/index.ts`
222- Do NOT use Hono serveStatic middleware
223- **Static asset serving:** Use the utility functions to read and serve project files:
224```ts
225import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
255- Run migrations on startup or comment out for performance
256- Change table names when modifying schemas rather than altering
257- Export clear query functions with proper TypeScript typing
258259## Common Gotchas and Solutions
Townie-02useBranches.tsx1 match
3const ENDPOINT = "/api/project-branches";
45export function useBranches (projectId: string) {
6const [data, setData] = useState<any>(null);
7const [loading, setLoading] = useState(true);