Skip to content

Documentation / @super-line/server / SuperLineServer

Interface: SuperLineServer<C, A, HK> ​

Defined in: index.ts:602

A running super-line server, returned by createSuperLineServer.

Type Parameters ​

C ​

C extends Contract

A ​

A extends AuthResult<C>

HK ​

HK extends string = never

Properties ​

cluster ​

readonly cluster: ClusterView

Defined in: index.ts:612

Asynchronous, cluster-wide introspection backed by the adapter's presence directory.


local ​

readonly local: LocalView

Defined in: index.ts:610

Synchronous, node-local introspection (connections, rooms, topics on this process).


nodeId ​

readonly nodeId: string

Defined in: index.ts:604

This node's stable id (unique per server process).


nodeKey? ​

readonly optional nodeKey?: string

Defined in: index.ts:608

Stable replica identity supplied by the host, if configured.


nodeName ​

readonly nodeName: string

Defined in: index.ts:606

This node's friendly name (from nodeName/SUPER_LINE_NODE_NAME, else a short nodeId slice).


ready ​

readonly ready: Promise<void>

Defined in: index.ts:665

Resolves once everything construction started has landed: the reply channel is subscribed and every transport has finished start(). Rejects if one of them failed.

createSuperLineServer is synchronous, so a node can be handed back before it is listening — which is real for a transport whose start is async (libp2p awaits node.handle), and harmless for one where the host owns the socket (a WebSocket transport over your own http.Server). Await this before dialing a server you just built.

Methods ​

batch() ​

batch(ops): Promise<void>

Defined in: index.ts:650

Apply several row writes, across row collections, as ONE atomic batch: every op is schema-validated (policy-free, like a co-write) and either all commit or none do. CRDT document collections can't join.

Parameters ​

ops ​

ServerCollectionOp[]

Returns ​

Promise<void>


close() ​

close(): Promise<void>

Defined in: index.ts:666

Returns ​

Promise<void>


collection() ​

collection<N>(name): N extends CrdtCollectionName<C> ? ServerCrdtCollectionHandle<DocOf<C, N>> : ServerCollectionHandle<RowOf<C, N>>

Defined in: index.ts:643

Server-authoritative handle for a contract collection, typed by the contract: an LWW row collection gives ServerCollectionHandle (insert/update/delete), a CRDT document collection gives ServerCrdtCollectionHandle (create/open). Throws NOT_FOUND if no matching backend is configured or the name isn't declared.

Type Parameters ​

N ​

N extends string

Parameters ​

name ​

N

Returns ​

N extends CrdtCollectionName<C> ? ServerCrdtCollectionHandle<DocOf<C, N>> : ServerCollectionHandle<RowOf<C, N>>


conditionalBatch() ​

conditionalBatch(conditions, ops): Promise<boolean>

Defined in: index.ts:655

Like SuperLineServer.batch, but only while every condition's stored row still matches its filter. Resolves false and applies nothing when one doesn't.

Parameters ​

conditions ​

ServerRowCondition[]

ops ​

ServerCollectionOp[]

Returns ​

Promise<boolean>


forRole() ​

forRole<R>(role): RoleLens<C, R>

Defined in: index.ts:636

Lens for role-scoped sends, e.g. forRole('user').publish('feed', data).

Type Parameters ​

R ​

R extends string

Parameters ​

role ​

R

Returns ​

RoleLens<C, R>


implement() ​

implement(handlers): SuperLineServer<C, A, HK>

Defined in: index.ts:620

Register handlers for shared + per-role requests (chainable). Keys handled by a plugin (HK) are subtracted.

Parameters ​

handlers ​

SubtractHandlers<Handlers<C, A>, HK>

Returns ​

SuperLineServer<C, A, HK>


isOnline() ​

isOnline(userId): Promise<boolean>

Defined in: index.ts:614

Whether a user (by identify key) has at least one live connection anywhere.

Parameters ​

userId ​

string

Returns ​

Promise<boolean>


publish() ​

publish<T>(topic, data): void

Defined in: index.ts:624

Publish a SHARED topic to all subscribers (server-only publish).

Type Parameters ​

T ​

T extends string | number | symbol

Parameters ​

topic ​

T

data ​

EmitData<TopicsOf<StcOf<C["shared"]>>[T]>

Returns ​

void


room() ​

room(name): Room<C>

Defined in: index.ts:622

Mixed-role connection group; broadcast() sends a shared contract event to members.

Parameters ​

name ​

string

Returns ​

Room<C>


subscribe() ​

subscribe<T>(topic, handler): Unsubscribe

Defined in: index.ts:631

Subscribe SERVER-side to a shared topic, cluster-wide. The callback fires for a publish from any node — including this one (local echo, delivered in-process with no round-trip). meta.from is the publishing node; self-exclude with if (meta.from === srv.nodeId) return. Returns an unsubscribe fn.

Type Parameters ​

T ​

T extends string | number | symbol

Parameters ​

topic ​

T

handler ​

(data, meta) => void

Returns ​

Unsubscribe


toConn() ​

toConn(id): ConnTarget<C>

Defined in: index.ts:616

Target a single connection by id, on whatever node holds it (cross-node emit/close).

Parameters ​

id ​

string

Returns ​

ConnTarget<C>


toUser() ​

toUser(userId): UserTarget<C>

Defined in: index.ts:618

Target all of a user's connections (by identify key) across nodes (emit/disconnect).

Parameters ​

userId ​

string

Returns ​

UserTarget<C>

Released under the MIT License.