3import { Hono } from "https://esm.sh/hono@3.11.7";
4import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
5import { runMigrations } from "./database/migrations.ts";
67// Import route modules
19});
2021// Initialize database on startup
22let dbInitialized = false;
23async function initializeDatabase() {
24if (!dbInitialized) {
25try {
26await runMigrations();
27dbInitialized = true;
28console.log('Database initialized successfully');
29} catch (error) {
30console.error('Database initialization failed:', error);
31}
32}
35// Health check endpoint
36app.get('/api/health', async (c) => {
37await initializeDatabase();
38
39return c.json({
41timestamp: new Date().toISOString(),
42version: '1.0.0',
43database: dbInitialized ? 'connected' : 'disconnected'
44});
45});
58// Serve main application
59app.get("/", async (c) => {
60await initializeDatabase();
61
62let html = await readFile("/frontend/index.html", import.meta.url);
87// Role-based dashboard routes
88app.get("/student/*", async (c) => {
89await initializeDatabase();
90let html = await readFile("/frontend/index.html", import.meta.url);
91
100101app.get("/teacher/*", async (c) => {
102await initializeDatabase();
103let html = await readFile("/frontend/index.html", import.meta.url);
104
113114app.get("/admin/*", async (c) => {
115await initializeDatabase();
116let html = await readFile("/frontend/index.html", import.meta.url);
117
126127app.get("/parent/*", async (c) => {
128await initializeDatabase();
129let html = await readFile("/frontend/index.html", import.meta.url);
130
140// Catch-all route for SPA
141app.get("*", async (c) => {
142await initializeDatabase();
143let html = await readFile("/frontend/index.html", import.meta.url);
144
10getUserNotifications,
11createPayment
12} from "../database/queries.ts";
13import { processSchoolFeePayment, verifySchoolFeePayment } from "../services/mobile-money.ts";
14import type { ApiResponse, ParentDashboardData } from "../../shared/types.ts";
12getComplaintsByUser,
13createNotification
14} from "../database/queries.ts";
15import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
16import type { ApiResponse, AdminDashboardData, User, UserRole } from "../../shared/types.ts";
YESteacher.ts2 matches
13getUserNotifications,
14createNotification
15} from "../database/queries.ts";
16import type { ApiResponse, TeacherDashboardData } from "../../shared/types.ts";
17408}
409
410// TODO: Implement work hours logging in database
411// For now, return success
412const workHours = {
YESstudent.ts1 match
15createComplaint,
16getComplaintsByUser
17} from "../database/queries.ts";
18import type { ApiResponse, StudentDashboardData } from "../../shared/types.ts";
19
64}
65
66// Create or update user in database
67const user = await createOrUpdateUser(googleUser);
68
23import type { User, UserRole } from "../../shared/types.ts";
4import { createUser, getUserByEmail, updateUserLastLogin } from "../database/queries.ts";
56const GOOGLE_CLIENT_ID = Deno.env.get('GOOGLE_CLIENT_ID');
YESmigrations.ts3 matches
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
23// Database schema migrations for Xplicit E-learning platform
45export async function runMigrations() {
6console.log('Running database migrations...');
7
8// Users table
313`);
314315console.log('Database migrations completed successfully');
316}
317
24โโโ backend/
25โ โโโ auth/ # Authentication & authorization
26โ โโโ database/ # Database schemas & queries
27โ โโโ routes/ # API endpoints by user type
28โ โโโ services/ # Google Workspace integrations
Xplicit_E-learningindex.ts7 matches
4import { getCookie, setCookie, deleteCookie } from "https://esm.sh/hono@3.11.7/cookie";
5import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
6import { runMigrations, seedData } from './database/migrations.ts';
7import { getDashboardStats } from './database/queries.ts';
8import { GoogleOAuthService } from './auth/google-oauth.ts';
9import { GoogleWorkspaceService } from './services/google-workspace.ts';
20});
2122// Initialize database on startup
23try {
24await runMigrations();
25// Comment out seedData for production
26// await seedData();
27console.log('Database initialized successfully');
28} catch (error) {
29console.error('Database initialization failed:', error);
30}
3181const role = googleAuth.determineUserRole(googleUser.email);
82
83// Create or update user in database
84const user = {
85id: `user_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
94};
9596// Store user in database (you'd implement this in queries.ts)
97// await createOrUpdateUser(user);
98