hubShare
uses node:crypto
Set up the forge's pages to show the hub's codebase, read-only, in the hub's frame: what every page does first. Everyone is a reader (a token no one has, so no one is the maintainer).
import { hubCodebase, hubDir } from "#codebase/tcmts/hub"; import { HubFrame } from "#codebase/tcmts/hub/pages"; import { keepWarm, opened, pageFrame, shareCache } from "#codebase/tcmts/share"; import { randomBytes } from "node:crypto"; export function hubShare(): void { const dir = hubDir(); if (!opened.has(dir)) { process.env.TCM_SHARE_CODEBASE = dir; process.env.TCM_SHARE_PUBLIC = "1"; process.env.TCM_SHARE_TOKEN ||= randomBytes(24).toString("hex"); const served = { cb: hubCodebase(), cache: shareCache() }; opened.set(dir, served); keepWarm(served); } pageFrame.current = HubFrame; }
uses
- tcmts.hub.hubCodebase
- tcmts.hub.hubDir
- tcmts.hub.pages.HubFrame
- tcmts.share.keepWarm
- tcmts.share.opened
- tcmts.share.pageFrame
- tcmts.share.shareCache