Portal Community

What a Server Does

The IServer is the orchestration hub for a logical message domain. When a message arrives from the transport, the server receives raw bytes, runs them through the incoming pipeline, and delivers the processed envelope to subscribers. When the app calls send(), the server runs the outgoing pipeline and then calls transport.send().

ComponentTypeRole
transportITransportNetwork connection — receives/sends raw bytes
incomingPipelineIPipelineProcesses received messages hook-by-hook
outgoingPipelineIPipelineProcesses outgoing messages hook-by-hook
subscriptionManagerISubscriptionManagerRoutes processed envelopes to subscriber callbacks

Server Types

Servers are typed as 'bas' (BizFirstGO Application Server) or 'chat'. The type is informational — it can be used to differentiate pipeline configurations for different message domains:

type ServerType = 'bas' | 'chat';

Server Interface

export interface IServer {
  readonly id: string;                          // e.g., 'bas', 'chat-server'
  readonly type: ServerType;                    // 'bas' | 'chat'
  readonly status: TransportStatus;             // connection status
  readonly transport: ITransport;
  readonly incomingPipeline: IPipeline;
  readonly outgoingPipeline: IPipeline;
  readonly subscriptionManager: ISubscriptionManager;

  start(): Promise<void>;       // connects transport, begins message processing
  stop(): Promise<void>;        // disconnects transport, cleanup
  send(topic: string, body: unknown): Promise<void>; // outgoing message
}

Server Registration Flow

1

registerServer(registration)

Call edgeStream.registerServer({ id, type, url, transportConfig }). The facade creates a transport from config and instantiates a Server.

2

Add Hooks

Get the server with edgeStream.server('bas') and add hooks to incomingPipeline and/or outgoingPipeline.

3

Subscribe

Register subscriber callbacks via edgeStream.subscribe(serverId, topic, callback).

4

edgeStream.start()

Calls server.start() on all registered servers. Transport connects; the server begins processing messages.

Single Server Setup (Typical)

import { createEdgeStream, NormalizationHook } from 'edge-stream-js';
import { HookActivityLogger } from 'observability-hooks-js';

const stream = createEdgeStream({ logLevel: 'info' });

// Register one server for the entire application
stream.registerServer({
  id: 'bas',
  type: 'bas',
  name: 'BizFirst Application Server',
  url: '/hubs/edge-stream',
  transportConfig: {
    type: 'signalr',
    url: '/hubs/edge-stream',
    accessToken: authService.getToken,
    reconnect: { maxAttempts: 0, initialDelayMs: 1000, maxDelayMs: 30000, backoffMultiplier: 2 }
  }
});

const server = stream.server('bas')!;
server.incomingPipeline.addHook(new HookActivityLogger());
server.incomingPipeline.addHook(new NormalizationHook());

await stream.start();
One Server Per Domain In most BizFirstGO applications, a single 'bas' server handles all messages. Use multi-server patterns only when you need separate transport configurations, different pipeline setups, or isolated subscription namespaces for distinct message domains.