import { serve } from "@hono/node-server"; import { Hono } from "hono"; import { createClient } from "@libsql/client"; import { drizzle } from "drizzle-orm/libsql"; import * as schema from "./db/schema.js"; import authRouter, { getSession, LoginForm } from "./auth.js"; import { eq } from "drizzle-orm"; export const RP_ID = "localhost"; // "uneven.0m.nu"; export const ORIGIN = `http://${RP_ID}`; let app = new Hono(); export let db = drizzle(createClient({ url: "file:data.db" }), { schema }); app.get("/groups", async c => { let session = await getSession(c); if (!session) return c.html("Must be logged in"); let user = await db.query.userTable.findFirst({ where: user => eq(user.id, session.user.id), with: { groups: { with: { group: true } } } }); if (!user) return c.html("Huh?"); return c.html(); }); app.get("/", c => c.html( Uneven
)); let colors = ["red", "green", "blue"]; app.get("/button", async c => { let session = await getSession(c); return c.html( ); }); app.route("/auth", authRouter); serve({ fetch: app.fetch, port: 80, }, info => console.log(`Server is running on http://localhost:${info.port}`));