1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
3import { getJobPostings, getChatMessages } from "../database/queries.ts";
4
5const static_routes = new Hono();
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { createChatMessage, getChatMessages } from "../database/queries.ts";
3
4const chat = new Hono();
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { createJobPosting, getJobPostings, getJobPostingById } from "../database/queries.ts";
3
4const jobs = new Hono();
6
7/**
8 * Run database migrations to set up the schema
9 */
10export async function runMigrations() {
31 `);
32
33 console.log("Database migrations completed");
34}
16
17- Backend: Hono.js API framework
18- Database: SQLite for data persistence
19- Frontend: HTML, JavaScript with Tailwind CSS
20- Data Refresh: Polling for chat updates
24```
25โโโ backend/
26โ โโโ database/
27โ โ โโโ migrations.ts # Schema definitions
28โ โ โโโ queries.ts # DB query functions
221. Set up a `CLAUDE_API_KEY` environment variable in Val Town with your Anthropic API key
232. Configure your Notion integration to send webhooks to this endpoint
243. Ensure your Notion database has the following properties:
25 - URL (URL type)
26 - Name (Title type)
6const LEAGUE_STANDINGS_TABLE = "chess_league_standings_1";
7
8export async function setupDatabase() {
9 // Create users table
10 await sqlite.execute(`
3import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
4import { parseProject } from "https://esm.town/v/std/utils@85-main/index.ts";
5import { setupDatabase } from "./database/migrations.ts";
6import { getUsers, createUser, getUserById, updateUserStats } from "./database/queries.ts";
7import { createGame, getGame, updateGameState, getActiveGames, getUserGames } from "./database/game-queries.ts";
8import { getLeagueStandings, updateLeagueStandings } from "./database/league-queries.ts";
9
10// Initialize the Hono app
19app.use("/*", cors());
20
21// Setup database on startup
22app.use("*", async (c, next) => {
23 try {
24 await setupDatabase();
25 } catch (error) {
26 console.error("Database setup error:", error);
27 }
28 return next();
2import { cors } from "https://esm.sh/hono@3.11.7/middleware";
3import { serveFile, readFile } from "https://esm.town/v/std/utils@85-main/index.ts";
4import { initializeDatabase } from "./database/schema.ts";
5
6// Import routes
20});
21
22// Initialize database on startup
23app.use("*", async (c, next) => {
24 try {
25 await initializeDatabase();
26 } catch (error) {
27 console.error("Database initialization error:", error);
28 }
29 await next();
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getUserById } from "../database/queries.ts";
3import { getAuthenticatedUser } from "../auth.ts";
4