rxfy-server
v3.1.1
Published
Server-side live data library for rxfy
Readme
rxfy-server
Storage-agnostic server-side live data for rxfy. Write through the sync server, publish sync updates to subscribers, and sign the grants clients subscribe with — over a pluggable storage adapter.
Install
npm install rxfy-server
# peer deps: rxfy zod
# plus a storage adapter: rxfy-server-drizzle (Postgres) or rxfy-server-memory (in-memory)What it gives you
createSync({ storage, hub, secret })— the sync server.secretis the HMAC key for signing/verifying grants;storageis aSyncStorageadapter. Exposeslive.create/live.update/live.deletethat persist through the adapter and publishpatch/stalemessages, pluslive.renewto reissue an expiring grant. Generic over the adapter's binding, so it accepts only that adapter's resources.SyncStorage<TBinding>— the persistence port implemented by adapters (rxfy-server-drizzle, rxfy-server-memory).Resource<TInsert, TRow, TBinding>is the storage-neutral resource each adapter'sdefineResource/defineCollectionproduces.createResourceRegistry— a neutral, typed index of resources (optional;createSyncdoes not require it).createInMemoryHub— socket-keyed pub/sub routing that pushespatch/stalemessages to the sockets subscribed on verified grant frames.live.serve— a read-endpoint pass-through: parses the payload, signs a per-state grant (its claims name the channel and the entity topics served), and attaches it as$grant. Stateless — no hub interaction, no requester session.live.hydration— the one-call SSR payload: dehydrate the registry and embed the grants the render logged asgrants: string[].signGrant/verifyGrant— the HS256 grant primitives (the WebSocket transport verifies with the samesecret).
See the rxfy-server docs for the full walkthrough, and Storage adapters for picking a SyncStorage.
