@nosana/kit
Version:
Nosana KIT
29 lines (28 loc) • 832 B
TypeScript
/**
* URL protocol constants
*/
export declare const PROTOCOL: {
readonly HTTP: "http";
readonly HTTPS: "https";
readonly WS: "ws";
readonly WSS: "wss";
};
/**
* Converts an HTTP/HTTPS URL to a WebSocket URL (ws/wss).
* Replaces the protocol: http -> ws, https -> wss
*
* @param httpUrl The HTTP or HTTPS URL to convert
* @returns The WebSocket URL with the protocol replaced
* @throws NosanaError if the URL doesn't use HTTP/HTTPS protocol
* @throws TypeError if the URL is invalid
*
* @example
* ```ts
* convertHttpToWebSocketUrl('https://api.mainnet-beta.solana.com')
* // Returns: 'wss://api.mainnet-beta.solana.com'
*
* convertHttpToWebSocketUrl('http://localhost:8899')
* // Returns: 'ws://localhost:8899'
* ```
*/
export declare function convertHttpToWebSocketUrl(httpUrl: string): string;