summaryrefslogtreecommitdiff
path: root/src/index.tsx
diff options
context:
space:
mode:
authorMathias Magnusson <mathias@magnusson.space>2025-08-18 21:43:11 +0200
committerMathias Magnusson <mathias@magnusson.space>2025-08-18 21:43:11 +0200
commit3262d631fd1be55a5c85ede08d92a35c5fb7d2c4 (patch)
treefb2a09e159dc8677b7587cba8d4c69c4b1b70d8e /src/index.tsx
parent815de9906a014c2eb1a4fe2bd8cf1b3077f03c9c (diff)
downloaduneven-3262d631fd1be55a5c85ede08d92a35c5fb7d2c4.tar.gz
Get current user session
Diffstat (limited to 'src/index.tsx')
-rw-r--r--src/index.tsx19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/index.tsx b/src/index.tsx
index e029577..5975284 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -3,7 +3,7 @@ import { Hono } from "hono";
import { createClient } from "@libsql/client";
import { drizzle } from "drizzle-orm/libsql";
import { groupTable } from "./db/schema.js";
-import authRouter, { LoginForm } from "./auth.js";
+import authRouter, { getSession, LoginForm } from "./auth.js";
export const RP_ID = "localhost"; // "uneven.0m.nu";
export const ORIGIN = `http://${RP_ID}`;
@@ -38,13 +38,16 @@ app.get("/", c => c.html(
));
let colors = ["red", "green", "blue"];
-app.get("/button", c => c.html(
- <button
- hx-get="/button"
- hx-swap="outerHTML"
- style={{ backgroundColor: colors[Math.floor(Math.random() * colors.length)] }}
- >disco button!</button>
-));
+app.get("/button", async c => {
+ let session = await getSession(c);
+ return c.html(
+ <button
+ hx-get="/button"
+ hx-swap="outerHTML"
+ style={{ backgroundColor: colors[Math.floor(Math.random() * colors.length)] }}
+ >disco button! {session.user.name}</button>
+ );
+});
app.route("/auth", authRouter);