Replaces the legacy Bureau CMS stack (@bureaudouble/bureau, deno-sqlite-blob, Fresh-style RSC) with the fleet layout: a defineProgram schema over the legacy tables (rows carry over by id), the timeline-selected blob database (autokit.sqlite), the operator CLI and mf predeploy, the package-shipped admin with a plugin per table, and the /api rpc/mcp/openapi door. The pages still render as server components, wired like wtfutures: one Autokit session per process, the request's db minted once in a createStart request middleware, read as context.db by each page's server function and handed to the server components as a db prop; the rsc graph never imports the session module (tests/one-session.test.ts). French stays at / and English at /en, now through Autokit's locales: the *_en columns became the translationsJson bag beside their French base text. The integer order columns of persons, roles and resources became order keys (drag-to-reorder in the admin); media columns are stored-media lists resolved through autokit-media. The age gate is the same shared page for every visitor: a head script marks a visitor who already answered, before the first paint.
39 lines
1.5 KiB
TypeScript
39 lines
1.5 KiB
TypeScript
// Test-only server entry: production's `src/server.ts` with the page cache on Caddy's adapter
|
|
// (purging to `ONE_SESSION_PURGE_URL`), plus one route that commits a `sites` write through the
|
|
// app's session, as an admin save does, so a test can watch the purge it causes.
|
|
import { operatorBoot } from "@bureaudouble/autokit-operator/entry";
|
|
import { caddy } from "@bureaudouble/autokit-operator/page-cache";
|
|
import { serverFetch } from "@bureaudouble/autokit-operator/serve";
|
|
import handler, { createServerEntry } from "@tanstack/react-start/server-entry";
|
|
|
|
const app = await operatorBoot(() => import("../src/autokit/server.ts"));
|
|
|
|
const commitSites = async () => {
|
|
const session = await app.session();
|
|
const { sites } = await session.load(
|
|
session.query.sites.findMany((site) => site.select("id", "title").first(1)),
|
|
);
|
|
const site = sites.findMany.nodes[0];
|
|
if (site === undefined) return new Response("no site", { status: 500 });
|
|
// Rewrites the title it holds: a commit on `sites` that changes nothing visible.
|
|
await session.mutate({ sites: { update: [{ id: site.id, title: site.title }] } });
|
|
return Response.json({ committed: site.id });
|
|
};
|
|
|
|
export default createServerEntry({
|
|
fetch: serverFetch(
|
|
(request) =>
|
|
new URL(request.url).pathname === "/__one-session/commit"
|
|
? commitSites()
|
|
: handler.fetch(request),
|
|
import.meta.url,
|
|
"autokit",
|
|
{
|
|
app,
|
|
pageCache: {
|
|
authCookiePrefix: "autokit-auth",
|
|
adapter: caddy({ purgeUrl: process.env["ONE_SESSION_PURGE_URL"] ?? "" }),
|
|
},
|
|
},
|
|
),
|
|
});
|