Files
minabot/scripts/dashboard-preview.ts
syntaxbullet 084603bb6e Add new styles for home and landing pages
- Created home.css with comprehensive styles for the home page layout, including typography, buttons, and responsive design adjustments.
- Created landing.css to style the landing page, focusing on typography, layout, and responsive behavior for various screen sizes.
2026-09-04 11:50:24 +02:00

58 lines
1.7 KiB
TypeScript

// Isolated browser QA server. Never opens or changes the user's database.
import { fixture } from "../src/habits/test-fixture";
import { createApi } from "../src/api";
import index from "../src/index.html";
const f = fixture();
const origin = "http://127.0.0.1:3107";
const previewCookie = "minabot_dashboard_preview_session";
const app = createApi(
f.db,
{
origin,
clientId: "",
clientSecret: "",
cookieSecret: "preview-only-secret-at-least-32-characters",
},
undefined,
() => Date.parse("2026-09-04T12:00:00Z"),
);
const server = Bun.serve({
hostname: "127.0.0.1",
port: 3107,
routes: {
"/__preview/login": () =>
new Response(null, {
status: 302,
headers: {
Location: "/",
"Set-Cookie": `${previewCookie}=${"a".repeat(43)}; Path=/; HttpOnly; SameSite=Lax`,
},
}),
"/api/*": async (request) => {
// Translate only the preview cookie; never use or overwrite a real session.
const cookie = request.headers
.get("cookie")
?.split(";")
.map((value) => value.trim())
.find((value) => value.startsWith(`${previewCookie}=`));
const headers = new Headers(request.headers);
headers.set(
"cookie",
cookie ? cookie.replace(previewCookie, "minabot_session") : "",
);
const response = await app.fetch(new Request(request, { headers }));
const setCookie = response.headers.get("set-cookie");
if (setCookie)
response.headers.set(
"set-cookie",
setCookie.replace("minabot_session", previewCookie),
);
return response;
},
"/*": index,
},
development: true,
});
console.log(`Disposable dashboard preview: ${server.url}__preview/login`);