Sync / foldkit-sync/journal
documentHost
function · packages/sync/src/journal.ts:488
function documentHost<Message, Shared, Principal, RP = never>(
options: DocumentHostOptions<Message, Shared, Principal, RP> &
DocumentHostOptionsLayer<RP>,
): (request: Request) => Promise<Result.Result<Accepted, Response>>One document's Sync host, for any runtime that upgrades a request to a
socket: a Durable Object (foldkit-sync/do), or Node's ws. Each
upgrade is answered before the socket opens: refused (Result.fail, a
401 for a principal refused, a 500 for a resolver or journal that broke),
or accepted (Accepted): serve the socket once the runtime has opened
it, against the journal, as the principal it resolved, asking again while
it is open when revalidate says to; or abandon it when the runtime
never will, which releases what the upgrade built.