Kind: Interface
Source: packages/websockets/interfaces/web-socket-server.interface.ts
Part of: Websockets
WebSocketServerOptions defines the configuration required to initialize a WebSocket server. It specifies the network port the server listens on and the namespace used to scope or route WebSocket connections within the application.
Properties
| Property | Type |
|---|---|
port | number |
namespace | string |
Diagram
mermaidgraph LR A[Application Configuration] --> B[WebSocketServerOptions] B --> C[port: number] B --> D[namespace: string] C --> E[WebSocket Server Listener] D --> F[Connection Namespace / Route]
Usage
tsimport type { WebSocketServerOptions } from './interfaces/web-socket-server.interface';
const websocketOptions: WebSocketServerOptions = {
port: 3001,
namespace: '/notifications',
};
// Pass the options when creating or configuring the WebSocket server.
createWebSocketServer(websocketOptions);
AI Coding Instructions
- Provide a valid, available TCP port as
port; avoid conflicting with the application's HTTP server port unless shared-server support exists. - Use a consistent
namespaceformat, typically beginning with/, such as/chator/notifications. - Keep namespace values aligned with the client connection URL and any server-side routing or gateway configuration.
- Treat this interface as configuration-only; do not add runtime connection state or server instances to it.
How it works
WebSocketServerOptions is an exported TypeScript interface marked @publicApi. It describes an object with two required properties: [packages/websockets/interfaces/web-socket-server.interface.ts:1-7]
port: number— a numericportproperty. [packages/websockets/interfaces/web-socket-server.interface.ts:4-6]namespace: string— a stringnamespaceproperty. [packages/websockets/interfaces/web-socket-server.interface.ts:4-7]
The interface itself contains no runtime validation, error handling, or side effects. [packages/websockets/interfaces/web-socket-server.interface.ts:4-7]
Was this page helpful?