Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Real 404s: a test scans src/app so a new page beside an id page can't be 404'd

Claude966d8bc26263
diff --git a/src/server/auth.ts b/src/server/auth.ts
index 621b971d..7909fda6 100644
--- a/src/server/auth.ts
+++ b/src/server/auth.ts
@@ -3,8 +3,9 @@
* Then every page and API call needs a session cookie (from /login) or an API token
* (`Authorization: Bearer fuobe_…`).
*
- * Kept in a small JSON file next to the database, not in SQLite, so the proxy can check
- * requests with nothing but `fs` and `crypto`.
+ * Kept in a small JSON file next to the database, not in SQLite, so the proxy's sign-in check
+ * needs nothing but `fs` and `crypto`. (The proxy does open SQLite, for one primary-key lookup on
+ * record pages only, so an unknown id gets a real 404: src/server/records.ts.)
*/
import crypto from "node:crypto";
import fs from "node:fs";
diff --git a/tests/record-pages.test.ts b/tests/record-pages.test.ts
index c454a798..226fe7ec 100644
--- a/tests/record-pages.test.ts
+++ b/tests/record-pages.test.ts
@@ -40,6 +40,29 @@ describe("record pages (real 404s)", () => {
}
});
+ it("matches every id page in src/app, and none of the static pages beside them", () => {
+ // The table is written by hand: a page added later under a record path (/shorts/new, /cinema/templates)
+ // would be answered with the 404 page. Scan the app's pages so that can't go unnoticed.
+ const app = path.join(process.cwd(), "src/app");
+ const routes: string[] = [];
+ const walk = (dir: string, segs: string[]) => {
+ for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
+ if (e.isDirectory() && !(segs.length === 0 && e.name === "api") && !e.name.startsWith("_")) walk(path.join(dir, e.name), /^\(.*\)$/.test(e.name) ? segs : [...segs, e.name]);
+ else if (e.name === "page.tsx") routes.push(`/${segs.join("/")}`);
+ }
+ };
+ walk(app, []);
+ expect(routes.length).toBeGreaterThan(40);
+ // Ids the catalog answers for (apps, hub modes), not stored records: the proxy checks those itself.
+ const catalog = /^\/(apps|audio|video-tools|upscale)\/\[/;
+ for (const route of routes) {
+ if (!route.includes("[")) {
+ expect(recordForPath(route), route).toBeNull();
+ expect(unknownHubMode(route), route).toBe(false);
+ } else if (!catalog.test(route)) expect(recordForPath(route.replace(/\[[^\]]+\]/g, "x1")), route).not.toBeNull();
+ }
+ });
+
it("knows each hub's modes", () => {
expect(unknownHubMode("/audio/music")).toBe(false);
expect(unknownHubMode("/video-tools/trim/")).toBe(false);