1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { createUser, getUserByEmail, getUserPasswordHash, updateUserStatus } from "../database/queries.ts";
3import type { AuthResponse } from "../../shared/types.ts";
4
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 { runMigrations } from "./database/migrations.ts";
4import { authRoutes } from "./routes/auth.ts";
5import { chatRoutes } from "./routes/chat.ts";
16});
17
18// Initialize database on startup
19await runMigrations();
20
95// Helper functions for WebSocket broadcasting
96function broadcastToChat(chatId: string, message: any, excludeUserId?: string) {
97 // In a real implementation, you'd query the database for chat participants
98 // For now, broadcast to all connected clients except the sender
99 for (const [userId, socket] of connectedClients.entries()) {
105
106function broadcastToContacts(userId: string, message: any) {
107 // In a real implementation, you'd query the database for user's contacts
108 // For now, broadcast to all connected clients
109 for (const [contactId, socket] of connectedClients.entries()) {
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getCookie } from "https://esm.sh/hono@3.11.7/cookie";
3import { createDiscussion, getDiscussions, getDiscussionsByCategory } from "../database/queries.ts";
4import type { ApiResponse, Discussion } from "../../shared/types.ts";
5
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getCookie } from "https://esm.sh/hono@3.11.7/cookie";
3import { createLivestock, getLivestockByUserId, updateLivestock, deleteLivestock } from "../database/queries.ts";
4import type { ApiResponse, Livestock } from "../../shared/types.ts";
5
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getCookie } from "https://esm.sh/hono@3.11.7/cookie";
3import { createCrop, getCropsByUserId, updateCrop, deleteCrop } from "../database/queries.ts";
4import type { ApiResponse, Crop } from "../../shared/types.ts";
5
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
2
3// Database schema for RChat application
4export async function runMigrations() {
5 console.log("Running database migrations...");
6
7 // Users table
164 await sqlite.execute(`CREATE INDEX IF NOT EXISTS idx_chatroom_replies_post_id ON chatroom_replies (post_id)`);
165
166 console.log("Database migrations completed successfully!");
167}
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getCookie, setCookie } from "https://esm.sh/hono@3.11.7/cookie";
3import { createUser, getUserByUsername } from "../database/queries.ts";
4import type { ApiResponse, User } from "../../shared/types.ts";
5
26โโโ backend/
27โ โโโ index.ts # Main Hono server
28โ โโโ database/
29โ โ โโโ migrations.ts # Database schema
30โ โ โโโ queries.ts # Database operations
31โ โโโ routes/
32โ โโโ auth.ts # Authentication routes
54- **Backend**: Hono (TypeScript API framework)
55- **Frontend**: React with TypeScript
56- **Database**: SQLite
57- **Real-time**: WebSocket connections
58- **Styling**: TailwindCSS
15```
16โโโ backend/
17โ โโโ database/
18โ โ โโโ migrations.ts # Database schema setup
19โ โ โโโ queries.ts # Database query functions
20โ โโโ routes/
21โ โ โโโ auth.ts # Authentication routes
39
40- **Backend**: Hono.js API framework
41- **Database**: SQLite for data persistence
42- **Frontend**: React with TypeScript
43- **Styling**: TailwindCSS for responsive design
48The app is automatically deployed on Val Town. Simply access the HTTP endpoint to start using the platform.
49
50## Database Schema
51
52- **users**: User accounts with usernames
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getRecentMessages, createMessage } from "../database/queries.ts";
3import type { ChatMessage, ApiResponse } from "/shared/types.ts";
4