Documentation / @super-line/server / ServerOptions
Interface: ServerOptions<C, A>
Defined in: index.ts:198
Options for createSocketServer.
Type Parameters
C
C extends Contract
A
A extends AuthResult<C>
Properties
adapter?
optionaladapter?:Adapter
Defined in: index.ts:204
Cross-node fan-out adapter. Defaults to a per-server in-memory adapter.
authenticate
authenticate: (
req) =>Awaitable<A>
Defined in: index.ts:208
Runs at the HTTP upgrade. Return { role, ctx }, or throw to reject with 401.
Parameters
req
IncomingMessage
Returns
Awaitable<A>
authorizeSubscribe?
optionalauthorizeSubscribe?: (topic,ctx,conn) =>Awaitable<boolean|void>
Defined in: index.ts:214
Runs on each client subscribe. Return false or throw to deny.
Parameters
topic
string
ctx
CtxUnion<A>
conn
Returns
Awaitable<boolean | void>
backpressure?
optionalbackpressure?:Backpressure
Defined in: index.ts:225
Guard against slow consumers: when a connection's send buffer exceeds the limit, close or drop.
describeConn?
optionaldescribeConn?: (conn) =>Record<string,unknown>
Defined in: index.ts:212
Extra fields merged into the connection's cluster descriptor (e.g. { plan }). ctx is never auto-serialized.
Parameters
conn
Returns
Record<string, unknown>
heartbeat?
optionalheartbeat?:false| {interval?:number;maxMissed?:number; }
Defined in: index.ts:223
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?
optionalidentify?: (conn) =>string|undefined
Defined in: index.ts:210
Stable user key for a connection (powers cluster.byUser, isOnline, and toUser).
Parameters
conn
Returns
string | undefined
onConnection?
optionalonConnection?: (conn,ctx) =>void
Defined in: index.ts:227
Called once per accepted connection.
Parameters
conn
ctx
CtxUnion<A>
Returns
void
onDisconnect?
optionalonDisconnect?: (conn,ctx,code) =>void
Defined in: index.ts:229
Called when a connection closes, with the WebSocket close code.
Parameters
conn
ctx
CtxUnion<A>
code
number
Returns
void
onError?
optionalonError?: (error,info) =>void
Defined in: index.ts:231
Called for any error thrown in middleware/handlers (after the client is replied to).
Parameters
error
unknown
info
Returns
void
path?
optionalpath?:string
Defined in: index.ts:206
Only handle upgrades for this pathname; others are left untouched.
serializer?
optionalserializer?:Serializer
Defined in: index.ts:202
Wire serializer; MUST match the client. Defaults to jsonSerializer.
server?
optionalserver?:Server<typeofIncomingMessage, typeofServerResponse>
Defined in: index.ts:200
The http.Server to attach to (compose with Express/Fastify/Hono).
use?
optionaluse?:Middleware<A>[]
Defined in: index.ts:216
Middleware chain run before req/subscribe handlers (rate-limit, authz, logging, metrics).