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: {
92|------|-------------|--------|----------------------|
93| **Technology Failures** | System crashes, bugs, or technical issues | High | โข Robust testing procedures<br>โข Backup systems<br>โข Regular maintenance<br>โข Technical reviews |
94| **Integration Issues** | Problems connecting different systems | Medium-High | โข Early integration testing<br>โข API documentation<br>โข Proof of concepts<br>โข Technical architecture reviews |
95| **Performance Issues** | System not meeting performance requirements | Medium | โข Performance testing<br>โข Scalability planning<br>โข Load testing<br>โข Performance monitoring |
96| **Security Vulnerabilities** | Cybersecurity threats and data breaches | High | โข Security assessments<br>โข Regular updates and patches<br>โข Access controls<br>โข Security training |
77});
78
79// API Routes
80
81// Get comments for a specific post
82app.get("/api/comments/:postId", async c => {
83 try {
84 const postId = c.req.param("postId");
113
114// Post a new comment
115app.post("/api/comments", async c => {
116 try {
117 const body = await c.req.json();
146
147// Update comment reactions
148app.post("/api/comments/:id/react", async c => {
149 try {
150 const commentId = c.req.param("id");
190
191// Submit movie request
192app.post("/api/movie-requests", async c => {
193 try {
194 const body = await c.req.json();
215
216// Get movie requests (for admin)
217app.get("/api/movie-requests", async c => {
218 try {
219 const status = c.req.query("status") || "all";
240
241// Contact form submission
242app.post("/api/contact", async c => {
243 try {
244 const body = await c.req.json();
263
264// Get blog stats
265app.get("/api/stats", async c => {
266 try {
267 const commentCount = await sqlite.execute(
326 status: "healthy",
327 timestamp: new Date().toISOString(),
328 service: "Yetunde's Movie Review Hub API"
329 });
330});
19โ โ โโโ queries.ts # Database query functions
20โ โโโ routes/
21โ โ โโโ reports.ts # Crime report API endpoints
22โ โ โโโ static.ts # Static file serving
23โ โโโ index.ts # Main Hono server
37## Technology Stack
38
39- **Backend**: Hono (TypeScript API framework)
40- **Database**: SQLite
41- **Frontend**: React with TypeScript
43- **Styling**: TailwindCSS
44
45## API Endpoints
46
47- `GET /api/reports` - Get all crime reports (with optional location filtering)
48- `POST /api/reports` - Submit a new crime report
49- `GET /api/reports/stats` - Get crime statistics by type and area
50
51## Database Schema
74## Development
75
76The app automatically serves static files and provides a REST API for crime reports. The database is initialized on first run.
16await runMigrations();
17
18// API routes
19app.route("/api/jobs", jobs);
20app.route("/api/applications", applications);
21app.route("/api/chat", chat);
22
23// Static file serving and main page