INNER CODE UNIT · TypeScript

handleWebhookRequest

Beever-AI/beever-atlas · bot/src/index.ts:889

  async function handleWebhookRequest(req: IncomingMessage, res: ServerResponse): Promise<void> {
    if (req.destroyed) {
      // Client disconnected during the buffer window — short-circuit to avoid
      // attaching listeners to a dead stream. drain() will resolve the queue
      // entry's promise via .finally().
      try {
        res.writeHead(204);
        res.end();
      } catch {
        // res may also be destroyed (shared socket); ignore
      }
      return;
    }

    // Per-connection webhook endpoint (preferred for multi-workspace)
    const connWebhookMatch = req.method === "POST" && req.url?.match(/^\/api\/webhooks\/([^/]+)$/);
    if (connWebhookMatch) {
      await handleConnectionWebhook(req, res, chatManager, PORT, connWebhookMatch[1]);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…