1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { jwt } from "https://esm.sh/hono@3.11.7/jwt";
3import { createUser, getUserByEmail, getPasswordHashByEmail } from "../database/queries.ts";
4import { LoginRequest, RegisterRequest, UserProfile } from "../../shared/types.ts";
5import { email } from "https://esm.town/v/std/email";
30```
31โโโ backend/
32โ โโโ database/
33โ โ โโโ migrations.ts # Schema definitions
34โ โ โโโ queries.ts # DB query functions
33## Project Structure
34
35- `/backend`: Hono API server with SQLite database (Side Hustle Hub)
36- `/frontend`: React frontend with Tailwind CSS (Side Hustle Hub)
37- `/shared`: Shared types and utilities (Side Hustle Hub)
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { cors } from "https://esm.sh/hono@3.11.7/middleware";
3import { setupDatabase } from "./database/migrations.ts";
4import jobRoutes from "./routes/jobs.ts";
5import chatRoutes from "./routes/chat.ts";
18app.use("*", cors());
19
20// Initialize database on startup
21app.use("*", async (c, next) => {
22 try {
23 await setupDatabase();
24 } catch (error) {
25 console.error("Database setup error:", error);
26 }
27 return next();
4 addChatMessage,
5 NewChatMessage
6} from "../database/queries.ts";
7
8const chat = new Hono();
5 createJob,
6 NewJobPosting
7} from "../database/queries.ts";
8
9const jobs = new Hono();
6
7/**
8 * Initialize database tables
9 */
10export async function setupDatabase() {
11 // Create jobs table
12 await sqlite.execute(`
10- `/backend/` - Server-side code using Hono
11 - `/backend/index.ts` - Main API entry point
12 - `/backend/database/` - Database setup and queries
13 - `/backend/routes/` - API route handlers
14- `/frontend/` - Client-side code
2import { cors } from "https://esm.sh/hono@3.11.7/middleware";
3import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
4import { setupDatabase } from "./database/migrations.ts";
5import * as db from "./database/queries.ts";
6
7// Initialize the app
16app.use("*", cors());
17
18// Initialize database on startup
19app.use("*", async (c, next) => {
20 try {
21 await setupDatabase();
22 } catch (error) {
23 console.error("Database setup error:", error);
24 }
25 return next();
6export const PROGRESS_TABLE = 'crochet_progress';
7
8export async function setupDatabase() {
9 // Create tutorials table
10 await sqlite.execute(`