42 };
43
44 const response = await fetch('/api/orders', {
45 method: 'POST',
46 headers: {
104}
105
106// API Response types
107export interface ApiResponse<T = any> {
108 success: boolean;
109 data?: T;
15await runMigrations();
16
17// API Routes
18app.route("/api/reports", reports);
19app.route("/api/chat", chat);
20
21// Serve static files
49 };
50
51 const response = await fetch('/api/chat/messages', {
52 method: 'POST',
53 headers: {
32
33 try {
34 const response = await fetch('/api/reports', {
35 method: 'POST',
36 headers: {
23 const loadReports = async () => {
24 try {
25 const response = await fetch('/api/reports');
26 if (!response.ok) throw new Error('Failed to load reports');
27 const data = await response.json();
35 const loadMessages = async () => {
36 try {
37 const response = await fetch('/api/chat/messages');
38 if (!response.ok) throw new Error('Failed to load messages');
39 const data = await response.json();
14await initializeDatabase();
15
16// API routes
17app.route("/api/reports", reports);
18
19// Static file serving and main page
59 updateActiveNav();
60
61 // Enhanced contact form handling with API integration
62 const contactForm = document.getElementById('contact-form');
63 if (contactForm) {
75
76 try {
77 const response = await fetch('/api/contact', {
78 method: 'POST',
79 headers: {
119 }
120
121 // Enhanced movie request form with API integration
122 const movieRequestForm = document.getElementById('movie-request-form');
123 if (movieRequestForm) {
135
136 try {
137 const response = await fetch('/api/movie-requests', {
138 method: 'POST',
139 headers: {
178
179 try {
180 const response = await fetch('/api/comments', {
181 method: 'POST',
182 headers: {
226 async function loadComments(postId, page = 1) {
227 try {
228 const response = await fetch(`/api/comments/${postId}?page=${page}&limit=10`);
229 const result = await response.json();
230
278
279 try {
280 const response = await fetch(`/api/comments/${commentId}/react`, {
281 method: 'POST',
282 headers: {
416 async function loadBlogStats() {
417 try {
418 const response = await fetch('/api/stats');
419 const stats = await response.json();
420
18โ โ โโโ queries.ts # Database query functions
19โ โโโ routes/
20โ โ โโโ reports.ts # Weekly reports API
21โ โ โโโ chat.ts # Chat API
22โ โโโ index.ts # Main Hono server
23โโโ frontend/
33```
34
35## API Endpoints
36
37- `GET /api/reports` - Get all weekly reports
38- `POST /api/reports` - Submit a new weekly report
39- `GET /api/chat/messages` - Get chat messages
40- `POST /api/chat/messages` - Send a chat message
41
42## Getting Started
43
44This app runs on Val Town. The backend serves both the API and static files, with real-time updates for the chat functionality.
16 try {
17 setLoading(true);
18 const response = await fetch('/api/reports');
19 if (!response.ok) {
20 throw new Error('Failed to fetch reports');
40 const handleReportSubmit = async (reportData: any) => {
41 try {
42 const response = await fetch('/api/reports', {
43 method: 'POST',
44 headers: {