Tidy the structure the audit found
- The colour defaults have one source, server/src/themeDefaults.js, read by the server and the admin; the build stops if src/index.css disagrees with it - server/src/admin-schema.js split into admin-schema/, one file per entity plus columns.js (the registry checked identical) - loadOwned() in shape.js replaces the same three loads on four detail routes (every public route checked identical); one NO_STORE - One OrgLogo component for the org lists and the chapter map; an organization's own page now shows the same initials as the lists - One localISO() for the viewer's calendar day, in place of three - Boot refuses a descriptor dropdown value the table's CHECK doesn't allow, instead of it failing on save - Deleted the unused Other.tsx and white-background logo; chapters.ts is useCommunity.ts; isSuper() in the Panel; stale comments and docs corrected Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
048c7599ce
commit
f934b1dd93
44 changed files with 1187 additions and 1170 deletions
|
|
@ -28,12 +28,12 @@ import {
|
|||
updateRow,
|
||||
deleteRow,
|
||||
} from "../admin-crud.js";
|
||||
import { NO_STORE } from "../shape.js";
|
||||
|
||||
const entities = new Hono();
|
||||
|
||||
entities.use("*", requireAuth);
|
||||
|
||||
const NO_STORE = { "Cache-Control": "no-store" };
|
||||
|
||||
function entityOr404(c) {
|
||||
const name = c.req.param("entity");
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@
|
|||
|
||||
import { Hono } from "hono";
|
||||
import { requireAuth, requireRole } from "../auth.js";
|
||||
import { NO_STORE } from "../shape.js";
|
||||
|
||||
const admin = new Hono();
|
||||
|
||||
admin.use("*", requireAuth);
|
||||
|
||||
const NO_STORE = { "Cache-Control": "no-store" };
|
||||
|
||||
const STATUSES = ["new", "read", "actioned", "archived", "spam"];
|
||||
const MAX_LIMIT = 200;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import {
|
|||
} from "../auth.js";
|
||||
import { GoogleLoginError, finishLogin, googleConfig, startLogin } from "../googleAuth.js";
|
||||
import { failureLimit } from "../rateLimit.js";
|
||||
import { NO_STORE } from "../shape.js";
|
||||
|
||||
// On top of the per-IP limit where /login is mounted: five wrong
|
||||
// passwords for one email in 15 minutes locks that email for the
|
||||
|
|
@ -54,7 +55,6 @@ const auth = new Hono();
|
|||
// so both paths cost the same. Computed once at import.
|
||||
const DUMMY_HASH = hashPassword("this password is never correct");
|
||||
|
||||
const NO_STORE = { "Cache-Control": "no-store" };
|
||||
|
||||
auth.post("/login", async (c) => {
|
||||
let body;
|
||||
|
|
|
|||
|
|
@ -39,13 +39,13 @@ import {
|
|||
saveToLibrary,
|
||||
toolVersions,
|
||||
} from "../clips.js";
|
||||
import { NO_STORE } from "../shape.js";
|
||||
|
||||
const clips = new Hono();
|
||||
|
||||
clips.use("/clips", requireAuth, requireRole("admin"));
|
||||
clips.use("/clips/*", requireAuth, requireRole("admin"));
|
||||
|
||||
const NO_STORE = { "Cache-Control": "no-store" };
|
||||
|
||||
const RECENT = 50;
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ import {
|
|||
json,
|
||||
loadBlocks,
|
||||
loadLinks,
|
||||
loadOwned,
|
||||
marks,
|
||||
paragraphs,
|
||||
shapeSeries,
|
||||
|
|
@ -492,9 +493,7 @@ content.get("/events/:id", (c) => {
|
|||
|
||||
if (!row) return c.json({ error: "No such event" }, 404);
|
||||
|
||||
const links = loadLinks(db, "event", [id]).get(id) ?? [];
|
||||
const cards = loadBlocks(db, "event", [id], "card").get(id) ?? [];
|
||||
const body = loadBlocks(db, "event", [id], "body").get(id) ?? [];
|
||||
const { links, cards, body } = loadOwned(db, "event", id);
|
||||
const hosts = loadHosts(db, [id]).get(id) ?? [];
|
||||
|
||||
const people = db
|
||||
|
|
@ -602,9 +601,7 @@ content.get("/organizations/:id", (c) => {
|
|||
|
||||
if (!row) return c.json({ error: "No such organization" }, 404);
|
||||
|
||||
const links = loadLinks(db, "organization", [id]).get(id) ?? [];
|
||||
const cards = loadBlocks(db, "organization", [id], "card").get(id) ?? [];
|
||||
const body = loadBlocks(db, "organization", [id], "body").get(id) ?? [];
|
||||
const { links, cards, body } = loadOwned(db, "organization", id);
|
||||
|
||||
const organization = shapeOrganization(row, links, cards, body);
|
||||
const one = [organization];
|
||||
|
|
@ -684,9 +681,7 @@ content.get("/teams/:id", (c) => {
|
|||
|
||||
if (!row) return c.json({ error: "No such team" }, 404);
|
||||
|
||||
const links = loadLinks(db, "team", [id]).get(id) ?? [];
|
||||
const cards = loadBlocks(db, "team", [id], "card").get(id) ?? [];
|
||||
const body = loadBlocks(db, "team", [id], "body").get(id) ?? [];
|
||||
const { links, cards, body } = loadOwned(db, "team", id);
|
||||
|
||||
return json(c, { team: { ...shapeTeam(row, links, cards), blocks: body } });
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@ import {
|
|||
store,
|
||||
} from "../media.js";
|
||||
import { fetchImage, previewLink } from "../linkPreview.js";
|
||||
import { NO_STORE } from "../shape.js";
|
||||
|
||||
const media = new Hono();
|
||||
|
||||
media.use("*", requireAuth);
|
||||
|
||||
const NO_STORE = { "Cache-Control": "no-store" };
|
||||
|
||||
const MAX_LIST = 500;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import { fileURLToPath } from "node:url";
|
|||
import { Hono } from "hono";
|
||||
|
||||
import { metaFor, renderPage, robotsTxt, siteFor, sitemap } from "../pageMeta.js";
|
||||
import { CACHE } from "../shape.js";
|
||||
import { CACHE, NO_STORE } from "../shape.js";
|
||||
|
||||
const here = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ pages.get("*", (c, next) => {
|
|||
`pages: serving ${pathname} without its metadata: ${err.message}` +
|
||||
(err.code === "ENOENT" ? " (set SITE_CONFIG to the deployed site.json)" : ""),
|
||||
);
|
||||
return c.html(html, 200, { "Cache-Control": "no-store" });
|
||||
return c.html(html, 200, NO_STORE);
|
||||
}
|
||||
|
||||
// no-cache: a browser may keep the page but asks again each time.
|
||||
|
|
|
|||
|
|
@ -26,13 +26,13 @@
|
|||
import { Hono } from "hono";
|
||||
import { requireAuth, requireRole, ROLES } from "../auth.js";
|
||||
import { tx } from "../db.js";
|
||||
import { NO_STORE } from "../shape.js";
|
||||
|
||||
const panel = new Hono();
|
||||
|
||||
panel.use("*", requireAuth);
|
||||
panel.use("*", requireRole("superadmin"));
|
||||
|
||||
const NO_STORE = { "Cache-Control": "no-store" };
|
||||
|
||||
/* The counts on the overview. Table name is a literal from this
|
||||
list, never anything off the wire. */
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
import { Hono } from "hono";
|
||||
|
||||
import { asBool, json, loadBlocks, loadLinks, marks, paragraphs, splitLinks } from "../shape.js";
|
||||
import { asBool, json, loadOwned, marks, paragraphs, splitLinks } from "../shape.js";
|
||||
|
||||
const people = new Hono();
|
||||
|
||||
|
|
@ -175,9 +175,7 @@ people.get("/people/:id", (c) => {
|
|||
|
||||
if (!row) return c.json({ error: "No such person" }, 404);
|
||||
|
||||
const links = loadLinks(db, "person", [id]).get(id) ?? [];
|
||||
const cards = loadBlocks(db, "person", [id], "card").get(id) ?? [];
|
||||
const body = loadBlocks(db, "person", [id], "body").get(id) ?? [];
|
||||
const { links, cards, body } = loadOwned(db, "person", id);
|
||||
const { actions, socials, website, instagram } = splitLinks(links);
|
||||
|
||||
// Current first, then most recently ended. Within each, the same
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue