MakeDurableObjectClassOptions
MakeDurableObjectClassOptions =
object
Defined in: packages/@livestore/sync-cf/src/cf-worker/shared.ts:28
Properties
Section titled “Properties”enabledTransports?
Section titled “enabledTransports?”
optionalenabledTransports:Set<"http"|"ws"|"do-rpc">
Defined in: packages/@livestore/sync-cf/src/cf-worker/shared.ts:87
Enabled transports for sync backend
http: HTTP JSON-RPCws: WebSocketdo-rpc: Durable Object RPC calls (only works in combination with@livestore/adapter-cf)
Default
Section titled “Default”Set(['http', 'ws', 'do-rpc'])forwardHeaders?
Section titled “forwardHeaders?”
optionalforwardHeaders:ForwardHeadersOption
Defined in: packages/@livestore/sync-cf/src/cf-worker/shared.ts:64
Forward request headers to onPush/onPull callbacks for authentication.
This enables cookie-based or header-based authentication patterns where you need access to request headers inside the Durable Object.
Examples
Section titled “Examples”makeDurableObject({ forwardHeaders: ['cookie', 'authorization'], onPush: async (message, { headers }) => { const cookie = headers?.get('cookie') const session = await validateSession(cookie) },})makeDurableObject({ forwardHeaders: (request) => ({ 'x-user-id': request.headers.get('x-user-id') ?? '', 'x-session': request.headers.get('cookie')?.split('session=')[1]?.split(';')[0] ?? '', }), onPush: async (message, { headers }) => { const userId = headers?.get('x-user-id') },})
optionalhttp:object
Defined in: packages/@livestore/sync-cf/src/cf-worker/shared.ts:105
Custom HTTP response headers for HTTP transport These headers will be added to all HTTP RPC responses (Pull, Push, Ping)
responseHeaders?
Section titled “responseHeaders?”
optionalresponseHeaders:Record<string,string>
Example
Section titled “Example”{ http: { responseHeaders: { 'Access-Control-Allow-Origin': '*', 'Cache-Control': 'no-cache' } }}onPull()?
Section titled “onPull()?”
optionalonPull: (message,context) =>Effect.SyncOrPromiseOrEffect<void>
Defined in: packages/@livestore/sync-cf/src/cf-worker/shared.ts:31
Parameters
Section titled “Parameters”message
Section titled “message”SyncMessage.PullRequest
context
Section titled “context”Returns
Section titled “Returns”Effect.SyncOrPromiseOrEffect<void>
onPullRes()?
Section titled “onPullRes()?”
optionalonPullRes: (message) =>Effect.SyncOrPromiseOrEffect<void>
Defined in: packages/@livestore/sync-cf/src/cf-worker/shared.ts:32
Parameters
Section titled “Parameters”message
Section titled “message”SyncMessage.PullResponse | InvalidPullError
Returns
Section titled “Returns”Effect.SyncOrPromiseOrEffect<void>
onPush()?
Section titled “onPush()?”
optionalonPush: (message,context) =>Effect.SyncOrPromiseOrEffect<void>
Defined in: packages/@livestore/sync-cf/src/cf-worker/shared.ts:29
Parameters
Section titled “Parameters”message
Section titled “message”SyncMessage.PushRequest
context
Section titled “context”Returns
Section titled “Returns”Effect.SyncOrPromiseOrEffect<void>
onPushRes()?
Section titled “onPushRes()?”
optionalonPushRes: (message) =>Effect.SyncOrPromiseOrEffect<void>
Defined in: packages/@livestore/sync-cf/src/cf-worker/shared.ts:30
Parameters
Section titled “Parameters”message
Section titled “message”SyncMessage.PushAck | InvalidPushError
Returns
Section titled “Returns”Effect.SyncOrPromiseOrEffect<void>
optionalotel:object
Defined in: packages/@livestore/sync-cf/src/cf-worker/shared.ts:109
baseUrl?
Section titled “baseUrl?”
optionalbaseUrl:string
serviceName?
Section titled “serviceName?”
optionalserviceName:string
storage?
Section titled “storage?”
optionalstorage: {_tag:"do-sqlite"; } | {_tag:"d1";binding:string; }
Defined in: packages/@livestore/sync-cf/src/cf-worker/shared.ts:77
Storage engine for event persistence.
- Default:
{ _tag: 'do-sqlite' }(Durable Object SQLite) - D1:
{ _tag: 'd1', binding: string }wherebindingis the D1 binding name in wrangler.toml.
If omitted, the runtime defaults to DO SQLite. For backwards-compatibility, if an env binding named
DB exists and looks like a D1Database, D1 will be used.
Trade-offs:
- DO SQLite: simpler deploy, data co-located with DO, not externally queryable
- D1: centralized DB, inspectable with DB tools, extra network hop and JSON size limits