Skip to main content
Glama
index.js1.36 kB
// src/helper/websocket/index.ts var WSContext = class { #init; constructor(init) { this.#init = init; this.raw = init.raw; this.url = init.url ? new URL(init.url) : null; this.protocol = init.protocol ?? null; } send(source, options) { this.#init.send(source, options ?? {}); } raw; binaryType = "arraybuffer"; get readyState() { return this.#init.readyState; } url; protocol; close(code, reason) { this.#init.close(code, reason); } }; var createWSMessageEvent = (source) => { return new MessageEvent("message", { data: source }); }; var defineWebSocketHelper = (handler) => { return ((...args) => { if (typeof args[0] === "function") { const [createEvents, options] = args; return async function upgradeWebSocket(c, next) { const events = await createEvents(c); const result = await handler(c, events, options); if (result) { return result; } await next(); }; } else { const [c, events, options] = args; return (async () => { const upgraded = await handler(c, events, options); if (!upgraded) { throw new Error("Failed to upgrade WebSocket"); } return upgraded; })(); } }); }; export { WSContext, createWSMessageEvent, defineWebSocketHelper };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Valerio357/bet-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server