1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { readFile } from "https://esm.town/v/std/utils/index.ts";
3import { runMigrations, seedSampleData } from "./database/migrations.ts";
4import studentsRoutes from "./routes/students.ts";
5import attendanceRoutes from "./routes/attendance.ts";
13});
14
15// Initialize database on startup
16let dbInitialized = false;
17async function initializeDatabase() {
18 if (!dbInitialized) {
19 await runMigrations();
32// Health check endpoint
33app.get("/api/health", async (c) => {
34 await initializeDatabase();
35 return c.json({
36 success: true,
43app.get("/", async (c) => {
44 try {
45 await initializeDatabase();
46
47 let html = await readFile("/frontend/index.html", import.meta.url);
76app.get("*", async (c) => {
77 try {
78 await initializeDatabase();
79
80 let html = await readFile("/frontend/index.html", import.meta.url);
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getAllJobs, createJob, deleteJob } from "../database/queries.ts";
3import type { CreateJobRequest, ApiResponse } from "../../shared/types.ts";
4
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { runMigrations } from "../database/migrations.ts";
3import {
4 createEvent, getEventById, getEvents, createRSVP,
5 getEventRSVPs, getUserRSVP
6} from "../database/queries.ts";
7import type { Event, EventRSVP, EventFilters, ApiResponse } from "../../shared/types.ts";
8
9const app = new Hono();
10
11// Initialize database on first request
12let dbInitialized = false;
13async function ensureDbInitialized() {
8 getAllBodyRegions,
9 searchApproaches
10} from "../database/queries.ts";
11
12const api = new Hono();
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getCookie, setCookie, deleteCookie } from "https://esm.sh/hono@3.11.7/cookie";
3import { createUser, getUserByEmail, createSession, getSessionUser, deleteSession } from "../database/queries.ts";
4import type { LoginForm, RegisterForm, ApiResponse, User } from "../../shared/types.ts";
5
25 )`);
26
27 console.log('Database migrations completed');
28}
29
45 `);
46
47 console.log('Database migrations completed');
48}
49
206 }
207
208 console.log('Database seeded with sample data');
209}
210
13```
14โโโ backend/
15โ โโโ database/
16โ โ โโโ migrations.ts # Database schema setup
17โ โ โโโ queries.ts # Database query functions
18โ โโโ routes/
19โ โ โโโ jobs.ts # Job posting API routes
43- `POST /api/chat/messages` - Send a new chat message
44
45## Database Schema
46
47### Jobs Table
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
2
3// Database schema setup for the tutoring platform
4export async function runMigrations() {
5 console.log("Running database migrations...");
6
7 // Users table
129 `);
130
131 console.log("Database migrations completed successfully!");
132}
15```
16โโโ backend/
17โ โโโ database/
18โ โ โโโ migrations.ts # Database schema setup
19โ โ โโโ queries.ts # Database query functions
20โ โโโ routes/
21โ โ โโโ auth.ts # Authentication routes