15app.use("*", cors());
16
17// Initialize database
18const TABLE_NAME = "rsvp_responses";
19async function initDatabase() {
20 await sqlite.execute(`CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
21 id INTEGER PRIMARY KEY AUTOINCREMENT,
30}
31
32// Initialize database on startup
33initDatabase();
34
35// Serve static files
51 }
52
53 // Insert into database
54 await sqlite.execute(
55 `INSERT INTO ${TABLE_NAME} (name, email, attending, guests, dietary_restrictions, message)
6
7- **RSVP Form**: Collects guest information including name, email, attendance status, number of guests, dietary restrictions, and optional messages
8- **Response Storage**: Stores all submissions in a SQLite database
9- **Response Viewing**: Provides a simple interface to view all submitted RSVPs
10- **Responsive Design**: Works well on both desktop and mobile devices
12## Project Structure
13
14- `/index.ts` - Main backend file with API endpoints and database setup
15- `/frontend/index.html` - Frontend RSVP form and response viewer
16
20- `GET /api/rsvp` - Get all RSVP responses
21
22## Database Schema
23
24The RSVP responses are stored in a SQLite table with the following schema:
5import { useState } from "react";
6
7const mockDatabase = [
8 {
9 title: "Half of a Yellow Sun",
47function filterBooks(query) {
48 const q = query.toLowerCase();
49 return mockDatabase.filter(({ title, author, genre, moods, duration }) => {
50 return (
51 title.toLowerCase().includes(q)
5import { cors } from "https://esm.sh/hono@3.11.7/middleware";
6import * as bcrypt from "https://esm.sh/bcryptjs@2.4.3";
7import * as queries from "../database/queries.ts";
8import type { ApiResponse } from "../../shared/types.ts";
9
5import { cors } from "https://esm.sh/hono@3.11.7/middleware";
6import * as bcrypt from "https://esm.sh/bcryptjs@2.4.3";
7import * as queries from "../database/queries.ts";
8import type { ApiResponse } from "../../shared/types.ts";
9
5import { setupAuthRoutes } from "./routes/auth.ts";
6import { setupChannelRoutes } from "./routes/channels.ts";
7import { runMigrations } from "./database/migrations.ts";
8
9// Initialize the app
18app.use("*", cors());
19
20// Run database migrations
21await runMigrations();
22
8 addUserToChannel,
9 removeUserFromChannel
10} from "../database/queries.ts";
11import { WebSocketHandler } from "../websocket/handler.ts";
12
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { createUser, getUserByUsername, updateLastLogin } from "../database/queries.ts";
3
4// Simple password hashing function (in production, use a proper hashing library)
7
8/**
9 * Run database migrations to set up the schema
10 */
11export async function runMigrations(): Promise<void> {
12 console.log("Running database migrations...");
13
14 // Create users table
49 `);
50
51 console.log("Database migrations completed");
52}
1import { addUserToChannel, removeUserFromChannel } from "../database/queries.ts";
2
3// Define the user connection type
47 this.channelConnections.get(userConnection.channelId)?.add(socket);
48
49 // Update database
50 addUserToChannel(userConnection.userId, userConnection.channelId);
51
107 }
108
109 // Update database
110 removeUserFromChannel(userConnection.userId, userConnection.channelId);
111