Files
bitgate/packages/site/serve.mjs
thePR0M3TH3AN b24bf3955d feat(site): BitGate landing page, integration guide, and live demo
A sibling of the BitLogin design system rather than a twin: the same
ink/paper/brass foundation and serif display, with verdigris — the patina brass
takes as it ages — where BitLogin uses its violet seal.

- index: the signature visual is the product's whole argument, one listing
  reaching four surfaces and getting four different verdicts
- docs: five-step integration, elements table, presets, common mistakes
- demo: the real engine running in the browser against an in-memory transport,
  so nothing is fetched or published. Add reports, restrict the seller, switch
  moderator identities, and watch every surface re-decide.

The widget bundle now re-exports the runtime and core entry points, because a
static page has no package manager — anything it might need has to be reachable
from the one file it loads.

Also fixes the site build reusing a stale widget bundle. It only rebuilt when
the file was missing, which is precisely how a broken demo ships: the page
loads, the module resolves, and an export added since the last build is
silently absent. Caught by running it.

vercel.json mirrors BitLogin's security headers, with connect-src widened to
wss: for relay traffic.
2026-08-09 20:30:03 -04:00

33 lines
1.1 KiB
JavaScript

#!/usr/bin/env node
/** Serve the built site locally for review. */
import { createServer } from "node:http";
import { readFile } from "node:fs/promises";
import { dirname, extname, join, normalize } from "node:path";
import { fileURLToPath } from "node:url";
const root = join(dirname(fileURLToPath(import.meta.url)), "dist");
const port = Number(process.env.PORT ?? 4174);
const TYPES = {
".html": "text/html; charset=utf-8",
".css": "text/css; charset=utf-8",
".js": "text/javascript; charset=utf-8",
".map": "application/json; charset=utf-8",
".svg": "image/svg+xml",
};
createServer(async (request, response) => {
const url = new URL(request.url ?? "/", "http://localhost");
let path = normalize(decodeURIComponent(url.pathname));
if (path.endsWith("/")) path += "index.html";
try {
const body = await readFile(join(root, path));
response.writeHead(200, { "content-type": TYPES[extname(path)] ?? "application/octet-stream" });
response.end(body);
} catch {
response.writeHead(404, { "content-type": "text/plain" });
response.end("Not found");
}
}).listen(port, () => console.log(`BitGate site → http://localhost:${port}`));