Remote / foldkit-remote-domain/server
pageReader
function · packages/remote-domain/src/adapter/resume.ts:82
function pageReader<A extends InProcessApi, M, Env = unknown, RP = never>(
api: A,
config: PageReaderConfig<A, M, Env, RP>,
): (
request: Request,
env: Env,
) => Layer.Layer<RemoteClient, RemoteUnauthenticated, RP | HostedOf<A, M>>The reader a page render reads through: DomainRemote.layer over the Api's
in-process client, as the principal resolvePrincipal decides from the
request, through the middleware middleware builds for that principal.
It only reads: it binds no command, so a mutation fails
RemoteMutationError, and a live open fails RemoteLiveError, since a navigation can be started from another site.
Every read and query is noted private for a render foldkit-ssr may keep
(PageReads), so a page read as someone is never served to anyone else.
The principal is decided, and the client built, when the reader is
provided; provide it to the pre-read itself
(Data.satisfy(…).pipe(Effect.provide(reader))).