From eedab2347c191badb48af9b618187c7a33f27240 Mon Sep 17 00:00:00 2001 From: ramvignesh-b Date: Tue, 12 May 2026 01:59:25 +0530 Subject: [PATCH] feat: add static file serving and refactor dashboard form to use FormData --- src/index.ts | 2 ++ src/views/dashboard.html | 62 ++++++++++++++++++++-------------------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/index.ts b/src/index.ts index ef8a144..5ba9e88 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ import { OpenAPIHono } from "@hono/zod-openapi"; import { Scalar } from "@scalar/hono-api-reference"; +import { serveStatic } from "hono/bun"; import { logger } from "hono/logger"; import { prettyJSON } from "hono/pretty-json"; import { config } from "./config"; @@ -41,6 +42,7 @@ app.use("*", prettyJSON()); app.get("/", (c) => c.redirect("/app")); +app.use("/app/*", serveStatic({ root: "./src/views" })); app.route("/auth", authRoutes); app.route("/api/config", configRoutes); app.route("/api", apiRoutes); diff --git a/src/views/dashboard.html b/src/views/dashboard.html index c4f7c02..716801d 100644 --- a/src/views/dashboard.html +++ b/src/views/dashboard.html @@ -11,7 +11,9 @@ - + @@ -54,20 +59,20 @@ -
@@ -126,7 +131,8 @@
-
- +
-
@@ -175,7 +182,7 @@
-
-
@@ -218,7 +225,7 @@

Provider Registry

- @@ -391,16 +398,16 @@
- + Connect -
@@ -505,24 +512,17 @@ return; } - const name = document.getElementById('providerName').value.trim(); - const config = { - clientId: document.getElementById('clientId').value.trim(), - clientSecret: document.getElementById('clientSecret').value.trim(), - authUrl: document.getElementById('authUrl').value.trim(), - tokenUrl: document.getElementById('tokenUrl').value.trim(), - redirectUri: document.getElementById('redirectUri').value.trim() || undefined, - scope: document.getElementById('scope').value.trim(), - }; + const formData = new FormData(configForm); + const data = Object.fromEntries(formData.entries()); try { - const response = await fetch(`/api/config/${name}`, { + const response = await fetch(`/api/config/${data.providerName}`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${apiKey}` }, - body: JSON.stringify(config) + body: JSON.stringify(data) }); if (!response.ok) throw new Error(await response.text());