Skip to content

Documentation / @super-line/server / SuperLineServerOptions

Interface: SuperLineServerOptions<C, A>

Defined in: index.ts:243

Options for createSuperLineServer.

Type Parameters

C

C extends Contract

A

A extends AuthResult<C>

Properties

adapter?

optional adapter?: Adapter

Defined in: index.ts:249

Cross-node fan-out adapter. Defaults to a per-server in-memory adapter.


authenticate

authenticate: (handshake) => Awaitable<A>

Defined in: index.ts:256

Authenticate a connection from its normalized Handshake. Return { role, ctx }, or throw to reject.

Parameters

handshake

Handshake

Returns

Awaitable<A>


authorizeSubscribe?

optional authorizeSubscribe?: (topic, ctx, conn) => Awaitable<boolean | void>

Defined in: index.ts:262

Runs on each client subscribe. Return false or throw to deny.

Parameters

topic

string

ctx

CtxUnion<A>

conn

Conn

Returns

Awaitable<boolean | void>


describeConn?

optional describeConn?: (conn) => Record<string, unknown>

Defined in: index.ts:260

Extra fields merged into the connection's cluster descriptor (e.g. { plan }). ctx is never auto-serialized.

Parameters

conn

Conn

Returns

Record<string, unknown>


heartbeat?

optional heartbeat?: false | { interval?: number; maxMissed?: number; }

Defined in: index.ts:271

Heartbeat: one timer pings every connection each interval ms (updating conn.lastPingAt/lastPongAt). Set maxMissed to terminate a connection that misses that many consecutive pongs. false disables it. Defaults to { interval: 30_000 } (no reaping).


identify?

optional identify?: (conn) => string | undefined

Defined in: index.ts:258

Stable user key for a connection (powers cluster.byUser, isOnline, and toUser).

Parameters

conn

Conn

Returns

string | undefined


inspector?

optional inspector?: boolean | { redact?: string[]; }

Defined in: index.ts:277

Enable the read-only Control Center inspector: emit msg.* telemetry and accept inspector clients. The WS transport must also be created with inspector: true to negotiate the superline.inspector.v1 subprotocol. Default off; dev / trusted-network only.


nodeName?

optional nodeName?: string

Defined in: index.ts:254

Friendly name for this node, surfaced in srv.nodeName, the cluster descriptor, and the Control Center topology. Defaults to SUPER_LINE_NODE_NAME or a short slice of nodeId.


onConnection?

optional onConnection?: (conn, ctx) => void

Defined in: index.ts:285

Called once per accepted connection.

Parameters

conn

Conn

ctx

CtxUnion<A>

Returns

void


onDisconnect?

optional onDisconnect?: (conn, ctx, code) => void

Defined in: index.ts:287

Called when a connection closes, with the WebSocket close code.

Parameters

conn

Conn

ctx

CtxUnion<A>

code

number

Returns

void


onError?

optional onError?: (error, info) => void

Defined in: index.ts:289

Called for any error thrown in middleware/handlers (after the client is replied to).

Parameters

error

unknown

info

MiddlewareInfo

Returns

void


serializer?

optional serializer?: Serializer

Defined in: index.ts:247

Wire serializer; MUST match the client. Defaults to jsonSerializer.


stores?

optional stores?: Record<string, ServerStore>

Defined in: index.ts:283

Pluggable persisted-state Stores, keyed by name ({ scene: crdtStoreServer(), config: memoryStoreServer() }). Each is the server half of a Store pair; the client passes the matching client halves. Surfaced as srv.store.<name> and client.store.<name>. Stores are off-contract and untyped (ADR-0003).


transports

transports: ServerTransport[]

Defined in: index.ts:245

Client↔server transports to accept connections on (e.g. webSocketServerTransport({ server })).


use?

optional use?: Middleware<A>[]

Defined in: index.ts:264

Middleware chain run before req/subscribe handlers (rate-limit, authz, logging, metrics).

Released under the MIT License.