serverApiHost
uses node:url
The #tcm/host instance the codebase's generated modules import (the server library calls it), so server functions
see their call.
import type { Codebase } from "#codebase/tcmts/cli/codebase"; import type { ServerApiHost } from "#codebase/tcmts/cli/web"; import path from "node:path"; import { pathToFileURL } from "node:url"; export function serverApiHost(cb: Codebase): () => Promise<ServerApiHost> { let api: Promise<ServerApiHost> | undefined; return () => (api ??= import( pathToFileURL(path.join(cb.lay.cacheDir, "tcm-host.js")).href ) as Promise<ServerApiHost>); }