INNER CODE UNIT · TypeScript

startServer

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

function startServer(chatManager: ChatManager, discordGateway?: DiscordGatewaySupervisor): void {
  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.
   */

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…