Kind: Interface
Source: packages/websockets/interfaces/gateway-metadata.interface.ts
Part of: Websockets
External interface
GatewayMetadata defines the configuration used to initialize and operate a WebSocket gateway. It captures the gateway namespace, HTTP path, client-serving behavior, transport adapters/parsers, and connection or heartbeat timeout settings.
Properties
| Property | Type |
|---|---|
namespace | `string |
path | string |
serveClient | boolean |
adapter | any |
parser | any |
connectTimeout | number |
pingTimeout | number |
pingInterval | number |
upgradeTimeout | number |
maxHttpBufferSize | number |
allowRequest | `( req: any, fn: (err: string |
transports | `Array<'polling' |
allowUpgrades | boolean |
perMessageDeflate | `boolean |
httpCompression | `boolean |
wsEngine | string |
initialPacket | any |
cookie | any |
cors | CorsOptions |
allowEIO3 | boolean |
destroyUpgrade | boolean |
destroyUpgradeTimeout | number |
Diagram
mermaidgraph LR GatewayMetadata --> Namespace["namespace: string | RegExp"] GatewayMetadata --> Path["path: string"] GatewayMetadata --> Client["serveClient: boolean"] GatewayMetadata --> Transport["adapter / parser"] GatewayMetadata --> Timeouts["Connection and upgrade timeouts"] GatewayMetadata --> Heartbeat["Ping interval and timeout"] GatewayMetadata --> Buffer["maxHttpBufferSize"] Timeouts --> Connect["connectTimeout"] Timeouts --> Upgrade["upgradeTimeout"] Heartbeat --> PingInterval["pingInterval"] Heartbeat --> PingTimeout["pingTimeout"]
Usage
tsimport type { GatewayMetadata } from './interfaces/gateway-metadata.interface';
const chatGatewayMetadata: GatewayMetadata = {
namespace: '/chat',
path: '/socket.io',
serveClient: true,
adapter: undefined,
parser: undefined,
connectTimeout: 10_000,
pingTimeout: 20_000,
pingInterval: 25_000,
upgradeTimeout: 10_000,
maxHttpBufferSize: 1e6,
};
// Pass this metadata to the gateway/WebSocket server initialization layer.
initializeGateway(chatGatewayMetadata);
AI Coding Instructions
- Use
namespaceto isolate gateway endpoints; provide aRegExponly when dynamic namespace matching is required. - Keep
pathaligned with the client connection configuration, or clients will fail to establish a WebSocket connection. - Configure
pingIntervalandpingTimeouttogether; ensure the timeout allows for expected network latency. - Treat
adapterandparseras integration points for the underlying WebSocket implementation and provide compatible instances. - Set
maxHttpBufferSizeconservatively to limit oversized payloads and reduce memory-pressure risks.
Relationships
- IMPORTS →
CorsOptions
Was this page helpful?