P4.2: HTML index at / — the install-page seed

GET / now serves a dense server-rendered console: each app with its
channels' current releases and every release's artifacts as direct
/download/<sha256> links. Read-only off the per-request db.json reload;
text escaped for HTML. A browser hitting the server root sees the store
instead of a 404.
This commit is contained in:
agra
2026-06-12 07:26:01 +03:00
parent 886b48630b
commit cf39589798
3 changed files with 129 additions and 1 deletions

View File

@@ -5,6 +5,8 @@
// `build/dist server run` on a test port in the background, waits for
// /healthz, and asserts every route against curl:
//
// * / → HTML index naming the app, with a
// /download/<sha> link
// * /healthz → {"status":"ok"}
// * /api/apps → the published app is listed
// * /api/apps/<slug> → app + its releases + channels
@@ -48,6 +50,24 @@ write_file :: (path: string, body: string) {
process.run(cmd);
}
// True iff `needle` occurs in `hay` (plain scan; bodies are small).
contains :: (hay: string, needle: string) -> bool {
if needle.len == 0 { return true; }
if needle.len > hay.len { return false; }
i := 0;
while i + needle.len <= hay.len {
j := 0;
ok := true;
while j < needle.len {
if hay[i + j] != needle[j] { ok = false; break; }
j += 1;
}
if ok { return true; }
i += 1;
}
return false;
}
// GET `path` and return the body (curl; 2s timeout so a dead server fails
// the test instead of hanging it).
fetch :: (path: string) -> string {
@@ -113,6 +133,12 @@ main :: () -> s32 {
print(" server up\n");
// ── routes ────────────────────────────────────────────────────────
process.assert(fetch_code("/") == "200", "/ serves the HTML index");
idx := fetch("/");
process.assert(contains(idx, "<title>dist</title>"), "index is the dist HTML page");
process.assert(contains(idx, "acme-app"), "index names the published app");
process.assert(contains(idx, "/download/"), "index links artifact downloads");
hz := parse_body(fetch("/healthz"), "/healthz", xx arena);
process.assert(get_str(hz, "status") == "ok", "/healthz status ok");