INNER CODE UNIT · TypeScript
handleBridge
Beever-AI/beever-atlas · bot/src/index.ts:872
const handleBridge = registerBridgeRoutes(chatManager, () => lazySyncIfNeeded(chatManager));
const webhookBuffer = new WebhookBuffer(chatManager);
/**
* Routes a webhook request to the right per-platform / per-connection handler.
*
* Used by both:
* 1. The HTTP server callback for live requests
* 2. WebhookBuffer.drain() for replayed requests after a chat-manager rebuild
*
* For replayed requests: Node's IncomingMessage stays paused after enqueue
* (no `data` listener was attached), so internally-buffered chunks remain
* available when readBody() attaches its listeners during drain. Slow / large
* payloads where data is still arriving when drain fires continue to stream
* through normally. Client disconnects during the buffer window are caught
* by the req.destroyed guard at the top.
*/
async function handleWebhookRequest(req: IncomingMessage, res: ServerResponse): Promise<void> {