serverHostFiles
The generated tcm-host.js and tcm-host.d.ts: the one host every module in a process shares.
import { codecSource } from "#codebase/tcmts/cli/codec"; import { createServerHost, HOST_DECLARATIONS } from "#codebase/tcmts/cli/server_api"; import { schemaCheckerSource } from "#codebase/tcmts/core/schema"; export function serverHostFiles(): { js: string; dts: string } { const js = `// generated by tcm — do not edit: the #tcm/host runtime (host protocol 1) import { AsyncLocalStorage } from "node:async_hooks"; import { randomBytes } from "node:crypto"; import { DatabaseSync } from "node:sqlite"; ${codecSource().replaceAll("export ", "")} ${schemaCheckerSource()} const host = (${createServerHost})({ AsyncLocalStorage, randomBytes, DatabaseSync, encode, decode, checkValue }); export const { call, dataDir, database, exclusive, transaction, enqueue, runJobs, checkSchedule, randomId, withCall, pendingCookies, startWorker, setSchedules, } = host; export { encode, decode, checkValue }; `; return { js, dts: HOST_DECLARATIONS }; }
uses
- tcmts.cli.codec.codecSource
- tcmts.cli.server_api.HOST_DECLARATIONS
- tcmts.cli.server_api.createServerHost
- tcmts.core.schema.schemaCheckerSource