25}
26
27// Initialize the database
28export async function initializeDatabase() {
29 await createStoriesTable();
30}
17## Project Structure
18
19- `/backend` - API routes, database, and story generation
20- `/frontend` - UI components, emoji selectors, and gallery
21- `/shared` - Shared types and utilities
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { cors } from "https://esm.sh/@hono/cors@0.0.6";
3import { getAllChatMessages, createChatMessage } from "../database/queries.ts";
4import type { ChatMessageFormData } from "../../shared/types.ts";
5
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { cors } from "https://esm.sh/@hono/cors@0.0.6";
3import { getAllJobPostings, getJobPostingById, createJobPosting } from "../database/queries.ts";
4import type { JobPostingFormData } from "../../shared/types.ts";
5
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { cors } from "https://esm.sh/@hono/cors@0.0.6";
3import { runMigrations } from "./database/migrations.ts";
4import jobRoutes from "./routes/jobs.ts";
5import chatRoutes from "./routes/chat.ts";
18});
19
20// Run database migrations on startup
21app.use("*", async (c, next) => {
22 try {
15
16- Backend: Hono (TypeScript)
17- Database: SQLite
18- Frontend: React with Tailwind CSS
19- Real-time: Server-sent events for chat updates
21## Project Structure
22
23- `/backend`: API routes and database logic
24- `/frontend`: React components and UI
25- `/shared`: Shared types and utilities
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { runMigrations } from "./database/migrations.ts";
3import authRoutes from "./routes/auth.ts";
4import projectRoutes from "./routes/projects.ts";
9- The **client-side entrypoint** is `/frontend/index.html`, which in turn imports `/frontend/index.tsx`, which in turn imports the React app from `/frontend/components/App.tsx`.
10
11[React Hono Example](https://www.val.town/x/stevekrouse/reactHonoExample) is a fuller featured example project, with a SQLite database table, queries, client-side CSS and a favicon, and some shared code that runs on both client and server.
21// API endpoint to get all themes
22app.get('/api/themes', async c => {
23 // In a real app, this would come from a database
24 const themes = [
25 {
128 const id = c.req.param('id');
129
130 // In a real app, this would come from a database
131 const themes = await app.fetch('/api/themes').then(res => res.json());
132 const theme = themes.find((t: any) => t.id === id);
139});
140
141// API endpoint to submit an order (this would typically store the order in a database)
142app.post('/api/orders', async c => {
143 try {
149 }
150
151 // In a real app, this would store the order in a database
152 // and potentially trigger a WhatsApp notification to the business owner
153
1# Discord Authentication with better-auth and SQLite
2
3This project implements Discord OAuth authentication using the `better-auth` library and Val Town's built-in SQLite database.
4
5## Project Structure
6
7- `/backend/index.ts` - Main entry point for the HTTP API
8- `/backend/database/schema.ts` - Database schema and migrations
9- `/backend/auth/discord.ts` - Discord authentication implementation
10- `/frontend/index.html` - Simple frontend for testing authentication