1import { ActionFunctionArgs } from "https://esm.sh/react-router@7.5.0?deps=react@18.2.0,react-dom@18.2.0";
2import { createMessage } from "../backend/database/queries.ts";
3
4export async function action({ request }: ActionFunctionArgs) {
245 const { pathname } = new URL(request.url);
246
247 // Initialize database
248 await sqlite.execute(`
249 CREATE TABLE IF NOT EXISTS ${KEY}_users (
30- [ ] add triggers to sidebar
31- [ ] add upload from SQL, CSV and JSON
32- [ ] add ability to connect to a non-val town Turso database
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
9const app = new Hono();
10
11// Initialize database before handling any requests
12app.use('*', async (c, next) => {
13 await db.initializeDatabase();
14 await db.cleanupExpiredData();
15 await next();
1import { sqlite } from "https://esm.town/v/std/sqlite";
2
3// Database initialization
4export async function initializeDatabase() {
5 try {
6 // Check schemas of existing tables
39 `);
40 } catch (error) {
41 console.error("Database initialization error:", error);
42 }
43}
8
9/**
10 * Retrieves previously generated fun facts from the memories database
11 * @returns Array of previous fun facts
12 */
47
48/**
49 * Inserts a fun fact into the memories database
50 * @param date Date for the fun fact in ISO format
51 * @param factText The fun fact text
1import { LoaderFunctionArgs } from "https://esm.sh/react-router@7.5.0?deps=react@18.2.0,react-dom@18.2.0";
2import { getTopicById, getMessageById, getMessagesByTopicId } from "../backend/database/queries.ts";
3
4export async function loader({ params }: LoaderFunctionArgs) {
1import { LoaderFunctionArgs } from "https://esm.sh/react-router@7.5.0?deps=react@18.2.0,react-dom@18.2.0";
2import { getTopicById, getMessagesByTopicId } from "../backend/database/queries.ts";
3
4export async function loader({ params }: LoaderFunctionArgs) {
1import { LoaderFunctionArgs } from "https://esm.sh/react-router@7.5.0?deps=react@18.2.0,react-dom@18.2.0";
2import { search } from "../backend/database/queries.ts";
3
4export async function loader({ request }: LoaderFunctionArgs) {
1import { LoaderFunctionArgs } from "https://esm.sh/react-router@7.5.0?deps=react@18.2.0,react-dom@18.2.0";
2import { getAllTopics } from "../backend/database/queries.ts";
3
4export async function loader() {