Kind: Interface
Source: src/helper/websocket/index.ts
Part of: Helper
Upgrade WebSocket Type
UpgradeWebSocket names the contract used by the WebSocket helper when an HTTP request is upgraded to a WebSocket connection. Code can accept or pass this interface without depending on a concrete upgrade implementation.
Diagram
mermaidgraph LR Request[HTTP Request] --> Upgrade[UpgradeWebSocket] Upgrade --> Connection[WebSocket Connection] Connection --> Handler[Application Handler]
Usage
tsimport type { UpgradeWebSocket } from './helper/websocket'
function registerUpgrade(
upgrade: UpgradeWebSocket,
): UpgradeWebSocket {
return upgrade
}
declare const platformUpgrade: UpgradeWebSocket
const upgrade = registerUpgrade(platformUpgrade)
AI Coding Instructions
- Import
UpgradeWebSocketwithimport typewhen it is only used for type checking. - Pass implementations through this interface instead of depending on platform-specific upgrade objects.
- Do not assume members or behavior that are not declared by the interface.
- Keep HTTP-to-WebSocket upgrade handling near the WebSocket helper integration.
Was this page helpful?