feat: add PWA manifest and service worker routes with coverage

This commit is contained in:
Codex
2026-02-18 12:39:10 +00:00
parent 78d72cc4a9
commit 6ff259c0d0
4 changed files with 55 additions and 0 deletions

View File

@@ -20,6 +20,14 @@ function html(status, markup) {
};
}
function text(status, body, contentType) {
return {
status,
headers: { "content-type": contentType || "text/plain; charset=utf-8" },
body,
};
}
function parseJSON(rawBody) {
if (!rawBody) {
return {};
@@ -112,6 +120,30 @@ function buildApp({ config }) {
return json(200, { ok: true });
}
if (method === "GET" && path === "/manifest.webmanifest") {
return text(
200,
JSON.stringify({
name: "X Article to Audio",
short_name: "XArtAudio",
start_url: "/",
display: "standalone",
background_color: "#1d232a",
theme_color: "#1d232a",
icons: [],
}),
"application/manifest+json; charset=utf-8",
);
}
if (method === "GET" && path === "/sw.js") {
return text(
200,
"self.addEventListener('install', () => self.skipWaiting()); self.addEventListener('activate', () => self.clients.claim());",
"application/javascript; charset=utf-8",
);
}
if (method === "GET" && path === "/") {
return html(200, renderHomePage({
authenticated: Boolean(userId),