1import { Hono } from "https://esm.sh/hono@3.11.7";
2import type { CreateExamRequest, ApiResponse, Exam, Question, User, ExamAttempt } from "../../shared/types.ts";
3import * as db from "../database/queries.ts";
4import { requireAuth, requireInstructor } from "./auth.ts";
5
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import type { CreateCourseRequest, ApiResponse, Course, User } from "../../shared/types.ts";
3import * as db from "../database/queries.ts";
4import { requireAuth, requireInstructor } from "./auth.ts";
5
2import { setCookie, getCookie, deleteCookie } from "https://esm.sh/hono@3.11.7/cookie";
3import type { LoginRequest, RegisterRequest, ApiResponse, User } from "../../shared/types.ts";
4import * as db from "../database/queries.ts";
5
6const auth = new Hono();
2
3export async function runMigrations() {
4 console.log("Running database migrations...");
5
6 // Users table
102 `);
103
104 console.log("Database migrations completed successfully");
105}
28```
29โโโ backend/
30โ โโโ database/
31โ โ โโโ migrations.ts # Database schema setup
32โ โ โโโ queries.ts # Database query functions
33โ โโโ routes/
34โ โ โโโ auth.ts # Authentication endpoints
54## Getting Started
55
561. The system will automatically set up the database on first run
572. Register as an instructor to create courses and exams
583. Students can register and enroll in available courses
62
63- **Backend**: Hono.js API framework
64- **Database**: SQLite with automatic migrations
65- **Frontend**: React with TypeScript
66- **Styling**: TailwindCSS
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { runMigrations } from "./database/migrations.ts";
3import authRoutes from "./routes/auth.ts";
4import advertisementRoutes from "./routes/advertisements.ts";
16});
17
18// Initialize database on startup
19await runMigrations();
20
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3import { USERS_TABLE } from "../database/migrations.ts";
4
5const debug = new Hono();
6
7// Test database connection
8debug.get('/test-db', async (c) => {
9 try {
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 * as queries from "./database/queries.ts";
5import eventsRouter from "./routes/events.ts";
6import todosRouter from "./routes/todos.ts";
14});
15
16// Initialize database endpoint
17app.get("/api/init", async (c) => {
18 try {
19 await runMigrations();
20 return c.json({ success: true, message: "Database initialized successfully" });
21 } catch (error) {
22 return c.json({ success: false, error: error.message }, 500);
31app.get("/api/dashboard", async (c) => {
32 try {
33 // Try to initialize database if not already done
34 try {
35 await runMigrations();
36 } catch (initError) {
37 // Database might already be initialized, continue
38 }
39
70 let html = await readFile("/frontend/index.html", import.meta.url);
71
72 // Try to inject initial dashboard data, but don't fail if database isn't ready
73 try {
74 // Try to initialize database if not already done
75 try {
76 await runMigrations();
77 } catch (initError) {
78 // Database might already be initialized, continue
79 }
80
6 updateOrderStatus,
7 getLeadWithDetails
8} from "../database/queries.ts";
9import type {
10 User,
6 getFollowUpsByUser,
7 getLeadWithDetails
8} from "../database/queries.ts";
9import type {
10 User,