{"id":30656028,"url":"https://github.com/ahoo-wang/fetcher","last_synced_at":"2026-04-26T18:00:47.612Z","repository":{"id":311263787,"uuid":"1043023698","full_name":"Ahoo-Wang/fetcher","owner":"Ahoo-Wang","description":"Fetcher is not just another HTTP client—it's a complete ecosystem designed for modern web development with native LLM streaming API support. Built on the native Fetch API, Fetcher provides an Axios-like experience with powerful features while maintaining an incredibly small footprint.","archived":false,"fork":false,"pushed_at":"2026-04-24T16:00:19.000Z","size":8214,"stargazers_count":16,"open_issues_count":11,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-24T16:12:15.036Z","etag":null,"topics":["ai","axios","client","event-source","event-stream","fetch","http","llm","openai","openai-api","restful-api","rpc","sse"],"latest_commit_sha":null,"homepage":"https://fetcher.ahoo.me/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ahoo-Wang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-08-23T01:52:29.000Z","updated_at":"2026-04-24T15:59:56.000Z","dependencies_parsed_at":"2025-11-27T14:10:37.828Z","dependency_job_id":null,"html_url":"https://github.com/Ahoo-Wang/fetcher","commit_stats":null,"previous_names":["ahoo-wang/fetcher"],"tags_count":307,"template":false,"template_full_name":null,"purl":"pkg:github/Ahoo-Wang/fetcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahoo-Wang%2Ffetcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahoo-Wang%2Ffetcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahoo-Wang%2Ffetcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahoo-Wang%2Ffetcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ahoo-Wang","download_url":"https://codeload.github.com/Ahoo-Wang/fetcher/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ahoo-Wang%2Ffetcher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32307015,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T17:23:19.671Z","status":"ssl_error","status_checked_at":"2026-04-26T17:23:19.195Z","response_time":129,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","axios","client","event-source","event-stream","fetch","http","llm","openai","openai-api","restful-api","rpc","sse"],"created_at":"2025-08-31T10:03:36.825Z","updated_at":"2026-04-26T18:00:47.606Z","avatar_url":"https://github.com/Ahoo-Wang.png","language":"TypeScript","readme":"# 🚀 Fetcher\n\n[![npm version](https://img.shields.io/npm/v/@ahoo-wang/fetcher.svg)](https://www.npmjs.com/package/@ahoo-wang/fetcher)\n[![Build Status](https://github.com/Ahoo-Wang/fetcher/actions/workflows/ci.yml/badge.svg)](https://github.com/Ahoo-Wang/fetcher/actions)\n[![codecov](https://codecov.io/gh/Ahoo-Wang/fetcher/graph/badge.svg?token=JGiWZ52CvJ)](https://codecov.io/gh/Ahoo-Wang/fetcher)\n[![License](https://img.shields.io/npm/l/@ahoo-wang/fetcher.svg)](https://github.com/Ahoo-Wang/fetcher/blob/main/LICENSE)\n[![npm downloads](https://img.shields.io/npm/dm/@ahoo-wang/fetcher.svg)](https://www.npmjs.com/package/@ahoo-wang/fetcher)\n[![npm bundle size](https://img.shields.io/bundlephobia/minzip/%40ahoo-wang%2Ffetcher)](https://www.npmjs.com/package/@ahoo-wang/fetcher)\n[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/Ahoo-Wang/fetcher)\n[![Storybook](https://img.shields.io/badge/Storybook-Interactive%20Docs-FF4785)](https://fetcher.ahoo.me/)\n\n**Ultra-lightweight • Modular • TypeScript-First • Interceptor-Powered • LLM Streaming API Support**\n\n## 🌟 Why Fetcher?\n\nFetcher is not just another HTTP client—it's a complete ecosystem designed for modern web development with native LLM\nstreaming API support. Built on the native Fetch API, Fetcher provides an Axios-like experience with powerful features\nwhile maintaining an incredibly small footprint.\n\n## 🚀 Core Features\n\n### 🎯 [`@ahoo-wang/fetcher`](./packages/fetcher) - The Foundation\n\nThe lightweight core that powers the entire ecosystem:\n\n- **⚡ Ultra-Lightweight**: Only 3KiB min+gzip - smaller than most alternatives\n- **🧭 Path \u0026 Query Parameters**: Built-in support for path (`{id}`/`:id`) and query parameters\n- **🔗 Interceptor System**: Request, response, and error interceptors with ordered execution for flexible middleware\n  patterns\n- **⏱️ Timeout Control**: Configurable request timeouts with proper error handling\n- **🔄 Fetch API Compatible**: Fully compatible with the native Fetch API\n- **🛡️ TypeScript Support**: Complete TypeScript definitions for type-safe development\n- **🧩 Modular Architecture**: Lightweight core with optional extension packages\n- **📦 Named Fetcher Support**: Automatic registration and retrieval of fetcher instances\n- **⚙️ Default Fetcher**: Pre-configured default fetcher instance for quick start\n\n### 🎨 [`@ahoo-wang/fetcher-decorator`](./packages/decorator) - Declarative APIs\n\nTransform your API interactions with clean, declarative service definitions:\n\n- **🎨 Clean API Definitions**: Define HTTP services using intuitive decorators\n- **🧭 Automatic Parameter Binding**: Path, query, header, and body parameters automatically bound\n- **⏱️ Configurable Timeouts**: Per-method and per-class timeout settings\n- **🔗 Fetcher Integration**: Seamless integration with Fetcher's named fetcher system\n- **⚡ Automatic Implementation**: Methods automatically implemented with HTTP calls\n- **📦 Metadata System**: Rich metadata support for advanced customization\n\n### 🔧 [`@ahoo-wang/fetcher-generator`](./packages/generator) - OpenAPI Code Generator\n\nA powerful TypeScript code generation tool that automatically generates type-safe API client code based on OpenAPI specifications. It is designed for general use cases and is also deeply optimized for the [Wow](https://github.com/Ahoo-Wang/Wow) Domain-Driven Design framework, providing native support for the CQRS architectural pattern.\n\n- **🎯 OpenAPI 3.0+ Support**: Full support for OpenAPI 3.0+ specifications (JSON/YAML)\n- **📦 TypeScript Code Generation**: Generates type-safe TypeScript interfaces, enums, and classes\n- **🔧 CLI Tool**: Easy-to-use command-line interface for code generation\n- **🎨 Decorator-Based APIs**: Generates decorator-based client classes for clean API interactions\n- **📋 Comprehensive Models**: Handles complex schemas including unions, intersections, enums, and references\n- **🚀 Fetcher Integration**: Seamlessly integrates with the Fetcher ecosystem packages\n- **📊 Progress Logging**: Friendly logging with progress indicators during generation\n- **📁 Auto Index Generation**: Automatically generates index.ts files for clean module organization\n- **🌐 Remote Spec Support**: Load OpenAPI specs directly from HTTP/HTTPS URLs\n- **🎭 Event Streaming**: Generates both regular and event-stream command clients\n- **🏗️ Domain-Driven Design Support**: Specialized support for Wow framework with aggregates, commands, queries, and events (CQRS patterns)\n\n### 🎯 [`@ahoo-wang/fetcher-eventbus`](./packages/eventbus) - Event Bus System\n\nA TypeScript event bus library providing multiple implementations for handling events: serial execution, parallel\nexecution, and cross-tab broadcasting.\n\n- **🔄 Serial Execution**: Execute event handlers in order of priority\n- **⚡ Parallel Execution**: Run event handlers concurrently for better performance\n- **🌐 Cross-Tab Broadcasting**: Broadcast events across browser tabs using BroadcastChannel API or localStorage fallback\n- **💾 Storage Messenger**: Direct cross-tab messaging with TTL and cleanup\n- **📦 Generic Event Bus**: Manage multiple event types with lazy loading\n- **🔧 Type-Safe**: Full TypeScript support with strict typing\n- **🧵 Async Support**: Handle both synchronous and asynchronous event handlers\n- **🔄 Once Handlers**: Support for one-time event handlers\n- **🛡️ Error Handling**: Robust error handling with logging\n- **🔌 Auto Fallback**: Automatically selects best available cross-tab communication method\n\n### 📡 [`@ahoo-wang/fetcher-eventstream`](./packages/eventstream) - Real-Time Streaming \u0026 LLM Support\n\nPower your real-time applications with Server-Sent Events support, specially designed for Large Language Model streaming\nAPIs:\n\n- **📡 Event Stream Conversion**: Converts `text/event-stream` responses to async generators of `ServerSentEvent` objects\n- **🔌 Side-Effect Module Import**: Automatically adds `eventStream()` and `jsonEventStream()` methods to the global `Response.prototype` for responses with\n  `text/event-stream` content\n  type\n- **📋 SSE Parsing**: Parses Server-Sent Events according to the specification, including data, event, id, and retry\n  fields\n- **🔄 Streaming Support**: Handles chunked data and multi-line events correctly\n- **💬 Comment Handling**: Properly ignores comment lines (lines starting with `:`) as per SSE specification\n- **🛡️ TypeScript Support**: Complete TypeScript type definitions\n- **⚡ Performance Optimized**: Efficient parsing and streaming for high-performance applications\n- **🤖 LLM Streaming Ready**: Native support for streaming responses from popular LLM APIs like OpenAI GPT, Claude, etc.\n\n### 🤖 [`@ahoo-wang/fetcher-openai`](./packages/openai) - OpenAI API Client\n\nType-safe OpenAI API client with native streaming support for chat completions:\n\n- **🎯 Type-Safe OpenAI Integration**: Complete TypeScript support for OpenAI Chat Completions API\n- **📡 Native Streaming Support**: Built-in support for streaming chat completions with Server-Sent Events\n- **🔧 Declarative API**: Clean, decorator-based API for OpenAI interactions\n- **⚡ Fetcher Integration**: Seamlessly integrates with the Fetcher ecosystem\n\n### 💾 [`@ahoo-wang/fetcher-storage`](./packages/storage) - Cross-Environment Storage\n\nA lightweight, cross-environment storage library with key-based storage and automatic environment detection:\n\n- **🌐 Cross-Environment Support**: Consistent API for browser localStorage/sessionStorage and in-memory storage\n- **📦 Ultra-Lightweight**: Only ~1KB gzip - minimal footprint\n- **🔔 Storage Change Events**: Listen for storage changes with event-driven architecture\n- **🔄 Automatic Environment Detection**: Automatically selects appropriate storage with fallback\n- **🛠️ Key-Based Storage**: Efficient key-based storage with built-in caching and serialization\n- **🔧 Custom Serialization**: Support for custom serialization strategies (JSON, Identity)\n- **📝 TypeScript Support**: Full TypeScript definitions for type-safe storage operations\n\n### 🧩 [`@ahoo-wang/fetcher-wow`](./packages/wow) - CQRS/DDD Framework Support\n\nFirst-class integration with the [Wow](https://github.com/Ahoo-Wang/Wow) CQRS/DDD framework:\n\n- **🔄 CQRS Pattern Implementation**: First-class support for Command Query Responsibility Segregation architectural\n  pattern\n- **🧱 DDD Primitives**: Essential Domain-Driven Design building blocks including aggregates, events, and value objects\n- **📦 Complete TypeScript Support**: Full type definitions for all Wow framework entities including commands, events,\n  and queries\n- **📡 Real-time Event Streaming**: Built-in support for Server-Sent Events to receive real-time command results and data\n  updates\n- **🚀 Command Client**: High-level client for sending commands to Wow services with both synchronous and streaming\n  responses\n- **🔍 Powerful Query DSL**: Rich query condition builder with comprehensive operator support for complex querying\n- **🔍 Query Clients**: Specialized clients for querying snapshot and event stream data with comprehensive query\n  operations:\n  - Counting resources\n  - Listing resources\n  - Streaming resources as Server-Sent Events\n  - Paging resources\n  - Retrieving single resources\n\n### 🔐 [`@ahoo-wang/fetcher-cosec`](./packages/cosec) - Enterprise Security\n\nSecure your applications with integrated authentication:\n\n- **🔐 Automatic Authentication**: Automatic CoSec authentication headers\n- **📱 Device Management**: Device ID management with localStorage persistence\n- **🔄 Token Refresh**: Automatic token refresh based on response codes (401)\n- **🌈 Request Tracking**: Unique request ID generation for tracking\n- **💾 Token Storage**: Secure token storage management\n\n## 📦 Package Ecosystem\n\n| Package                                                    | Description                                                                                                                                                                                                   | Version                                                                                                                                 | Size                                                                                                                                                   |\n| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| [`@ahoo-wang/fetcher`](./packages/fetcher)                 | **Core HTTP Client**\u003cbr/\u003eUltra-lightweight foundation with Axios-like API                                                                                                                                     | [![npm](https://img.shields.io/npm/v/@ahoo-wang/fetcher.svg)](https://www.npmjs.com/package/@ahoo-wang/fetcher)                         | [![size](https://img.shields.io/bundlephobia/minzip/%40ahoo-wang%2Ffetcher)](https://www.npmjs.com/package/@ahoo-wang/fetcher)                         |\n| [`@ahoo-wang/fetcher-decorator`](./packages/decorator)     | **Decorator Support**\u003cbr/\u003eDeclarative API service definitions                                                                                                                                                 | [![npm](https://img.shields.io/npm/v/@ahoo-wang/fetcher-decorator.svg)](https://www.npmjs.com/package/@ahoo-wang/fetcher-decorator)     | [![size](https://img.shields.io/bundlephobia/minzip/%40ahoo-wang%2Ffetcher-decorator)](https://www.npmjs.com/package/@ahoo-wang/fetcher-decorator)     |\n| [`@ahoo-wang/fetcher-eventstream`](./packages/eventstream) | **Real-Time Streaming \u0026 LLM Support**\u003cbr/\u003eServer-Sent Events (SSE) support with native LLM streaming API integration                                                                                          | [![npm](https://img.shields.io/npm/v/@ahoo-wang/fetcher-eventstream.svg)](https://www.npmjs.com/package/@ahoo-wang/fetcher-eventstream) | [![size](https://img.shields.io/bundlephobia/minzip/%40ahoo-wang%2Ffetcher-eventstream)](https://www.npmjs.com/package/@ahoo-wang/fetcher-eventstream) |\n| [`@ahoo-wang/fetcher-openai`](./packages/openai)           | **OpenAI Client**\u003cbr/\u003eType-safe OpenAI API client with streaming support for chat completions                                                                                                                 | [![npm](https://img.shields.io/npm/v/@ahoo-wang/fetcher-openai.svg)](https://www.npmjs.com/package/@ahoo-wang/fetcher-openai)           | [![size](https://img.shields.io/bundlephobia/minzip/%40ahoo-wang%2Ffetcher-openai)](https://www.npmjs.com/package/@ahoo-wang/fetcher-openai)           |\n| [`@ahoo-wang/fetcher-generator`](./packages/generator)     | **OpenAPI Code Generator**\u003cbr/\u003ePowerful TypeScript code generator from OpenAPI specifications, designed to be general-purpose with specialized support for Wow domain-driven design framework's CQRS patterns | [![npm](https://img.shields.io/npm/v/@ahoo-wang/fetcher-generator.svg)](https://www.npmjs.com/package/@ahoo-wang/fetcher-generator)     |                                                                                                                                                        |\n| [`@ahoo-wang/fetcher-openapi`](./packages/openapi)         | **OpenAPI TypeScript Types**\u003cbr/\u003eComplete TypeScript type definitions for OpenAPI 3.0+ specifications                                                                                                         | [![npm](https://img.shields.io/npm/v/@ahoo-wang/fetcher-openapi.svg)](https://www.npmjs.com/package/@ahoo-wang/fetcher-openapi)         | [![size](https://img.shields.io/bundlephobia/minzip/%40ahoo-wang%2Ffetcher-openapi)](https://www.npmjs.com/package/@ahoo-wang/fetcher-openapi)         |\n| [`@ahoo-wang/fetcher-storage`](./packages/storage)         | **Cross-Environment Storage**\u003cbr/\u003eLightweight storage library with key-based storage and automatic environment detection                                                                                      | [![npm](https://img.shields.io/npm/v/@ahoo-wang/fetcher-storage.svg)](https://www.npmjs.com/package/@ahoo-wang/fetcher-storage)         | [![size](https://img.shields.io/bundlephobia/minzip/%40ahoo-wang%2Ffetcher-storage)](https://www.npmjs.com/package/@ahoo-wang/fetcher-storage)         |\n| [`@ahoo-wang/fetcher-react`](./packages/react)             | **React Integration**\u003cbr/\u003eReact hooks and components for seamless data fetching with automatic re-rendering                                                                                                   | [![npm](https://img.shields.io/npm/v/@ahoo-wang/fetcher-react.svg)](https://www.npmjs.com/package/@ahoo-wang/fetcher-react)             | [![size](https://img.shields.io/bundlephobia/minzip/%40ahoo-wang%2Ffetcher-react)](https://www.npmjs.com/package/@ahoo-wang/fetcher-react)             |\n| [`@ahoo-wang/fetcher-wow`](./packages/wow)                 | **CQRS/DDD Framework Support**\u003cbr/\u003eFirst-class integration with the Wow CQRS/DDD framework                                                                                                                    | [![npm](https://img.shields.io/npm/v/@ahoo-wang/fetcher-wow.svg)](https://www.npmjs.com/package/@ahoo-wang/fetcher-wow)                 | [![size](https://img.shields.io/bundlephobia/minzip/%40ahoo-wang%2Ffetcher-wow)](https://www.npmjs.com/package/@ahoo-wang/fetcher-wow)                 |\n| [`@ahoo-wang/fetcher-cosec`](./packages/cosec)             | **Enterprise Security**\u003cbr/\u003eCoSec authentication integration                                                                                                                                                  | [![npm](https://img.shields.io/npm/v/@ahoo-wang/fetcher-cosec.svg)](https://www.npmjs.com/package/@ahoo-wang/fetcher-cosec)             | [![size](https://img.shields.io/bundlephobia/minzip/%40ahoo-wang%2Ffetcher-cosec)](https://www.npmjs.com/package/@ahoo-wang/fetcher-cosec)             |\n\n## 🚀 Getting Started\n\n### 📦 Installation\n\n```shell\n# Install the core package\nnpm install @ahoo-wang/fetcher\n\n# Or install with all extensions including LLM streaming support\nnpm install @ahoo-wang/fetcher @ahoo-wang/fetcher-decorator @ahoo-wang/fetcher-eventbus @ahoo-wang/fetcher-eventstream @ahoo-wang/fetcher-cosec\n\n# Using pnpm (recommended)\npnpm add @ahoo-wang/fetcher\n\n# Using yarn\nyarn add @ahoo-wang/fetcher\n```\n\n### ⚡ Quick Examples\n\n#### Basic HTTP Client\n\n```typescript\nimport { Fetcher } from '@ahoo-wang/fetcher';\n\n// Create a fetcher instance\nconst fetcher = new Fetcher({\n  baseURL: 'https://api.example.com',\n  timeout: 5000,\n});\n\n// GET request with path and query parameters\nconst response = await fetcher.get('/users/{id}', {\n  urlParams: {\n    path: { id: 123 },\n    query: { include: 'profile' },\n  },\n});\nconst userData = await response.json\u003cUser\u003e();\n\n// POST request with automatic JSON conversion\nconst createUserResponse = await fetcher.post('/users', {\n  body: { name: 'John Doe', email: 'john@example.com' },\n});\n```\n\n#### Declarative API Services\n\n```typescript\nimport { NamedFetcher } from '@ahoo-wang/fetcher';\nimport {\n  api,\n  get,\n  post,\n  path,\n  query,\n  body,\n} from '@ahoo-wang/fetcher-decorator';\n\n// Register a named fetcher\nconst apiFetcher = new NamedFetcher('api', {\n  baseURL: 'https://api.example.com',\n});\n\n// Define service with decorators\n@api('/users', { fetcher: 'api' })\nclass UserService {\n  @get('/')\n  getUsers(@query('limit') limit?: number): Promise\u003cUser[]\u003e {\n    throw autoGeneratedError(limit);\n  }\n\n  @post('/')\n  createUser(@body() user: User): Promise\u003cUser\u003e {\n    throw autoGeneratedError(user);\n  }\n\n  @get('/{id}')\n  getUser(@path('id') id: number): Promise\u003cUser\u003e {\n    throw autoGeneratedError(id);\n  }\n}\n\n// Use the service\nconst userService = new UserService();\nconst users = await userService.getUsers(10);\n```\n\n#### OpenAPI Code Generator\n\n```shell\n# Global Installation Generator CLI\nnpm install -g @ahoo-wang/fetcher-generator\n\n# Generate TypeScript code from OpenAPI specifications\nfetcher-generator generate -i ./openapi-spec.json -o ./src/generated\n\n# or generated from a remote URL\nfetcher-generator generate -i https://api.example.com/openapi.json -o ./src/generated\n```\n\n#### Powerful Interceptors\n\n```typescript\nimport { Fetcher } from '@ahoo-wang/fetcher';\n\nconst fetcher = new Fetcher({ baseURL: 'https://api.example.com' });\n\n// Add request interceptor with ordering\nfetcher.interceptors.request.use({\n  name: 'auth-interceptor',\n  order: 100,\n  intercept(exchange) {\n    exchange.request.headers.Authorization = 'Bearer ' + getAuthToken();\n  },\n});\n\n// Add response interceptor for logging\nfetcher.interceptors.response.use({\n  name: 'logging-interceptor',\n  order: 10,\n  intercept(exchange) {\n    console.log('Response:', exchange.response.status);\n  },\n});\n```\n\n#### Real-Time Streaming \u0026 LLM Support\n\n```typescript\nimport { Fetcher } from '@ahoo-wang/fetcher';\nimport '@ahoo-wang/fetcher-eventstream';\n\nconst fetcher = new Fetcher({ baseURL: 'https://api.example.com' });\n\n// Stream real-time events (generic SSE)\nconst response = await fetcher.get('/events');\nif (response.eventStream) {\n  for await (const event of response.eventStream()) {\n    console.log('Real-time event:', event);\n  }\n}\n\n// Stream LLM responses token by token\nconst llmResponse = await fetcher.post('/chat/completions', {\n  body: {\n    model: 'gpt-3.5-turbo',\n    messages: [{ role: 'user', content: 'Hello!' }],\n    stream: true,\n  },\n});\n\nif (llmResponse.jsonEventStream) {\n  // Specialized for JSON SSE events from LLM APIs\n  for await (const event of llmResponse.jsonEventStream\u003cChatCompletionChunk\u003e()) {\n    const content = event.data.choices[0]?.delta?.content || '';\n    process.stdout.write(content); // Real-time token output\n  }\n}\n```\n\n#### OpenAI Chat Completions\n\n```typescript\nimport { OpenAI } from '@ahoo-wang/fetcher-openai';\n\n// Initialize OpenAI client\nconst openai = new OpenAI({\n  baseURL: 'https://api.openai.com/v1',\n  apiKey: process.env.OPENAI_API_KEY!,\n});\n\n// Non-streaming chat completion\nconst response = await openai.chat.completions({\n  model: 'gpt-3.5-turbo',\n  messages: [{ role: 'user', content: 'Hello, how are you?' }],\n  stream: false,\n});\n\nconsole.log(response.choices[0].message.content);\n\n// Streaming chat completion\nconst stream = await openai.chat.completions({\n  model: 'gpt-3.5-turbo',\n  messages: [{ role: 'user', content: 'Tell me a story' }],\n  stream: true,\n});\n\nfor await (const chunk of stream) {\n  const content = chunk.data.choices[0]?.delta?.content || '';\n  process.stdout.write(content); // Real-time output\n}\n```\n\n#### Event Bus for Cross-Tab Communication\n\n```typescript\nimport {\n  BroadcastTypedEventBus,\n  SerialTypedEventBus,\n} from '@ahoo-wang/fetcher-eventbus';\n\n// Create a delegate for local event handling\nconst delegate = new SerialTypedEventBus\u003cstring\u003e('shared-events');\n\n// Create broadcast event bus for cross-tab communication\nconst eventBus = new BroadcastTypedEventBus(delegate);\n\n// Add event handler\neventBus.on({\n  name: 'user-action',\n  order: 1,\n  handle: action =\u003e console.log('User action:', action),\n});\n\n// Emit event locally and broadcast to other tabs\nawait eventBus.emit('button-clicked');\n```\n\n## 🎯 Integration Test Examples\n\nExplore comprehensive, production-ready implementations in our [integration-test](./integration-test) directory:\n\n### 🌐 HTTP Operations\n\n- **Typicode API Integration** - Complete integration with JSONPlaceholder API demonstrating real-world usage\n- **Parameter Handling** - Advanced path, query, and body parameter management\n- **Error Handling** - Comprehensive error handling patterns\n\n### 🔧 Advanced Patterns\n\n- **COSEC Authentication** - Enterprise-grade security integration with token management\n- **Interceptor Chains** - Complex middleware patterns with ordered execution\n- **Timeout Strategies** - Adaptive timeout configurations\n\n### 📡 Real-Time Features\n\n- **LLM Streaming API** - Native support for streaming responses from Large Language Models\n- **Server-Sent Events** - Real-time notifications and updates\n- **Streaming Data** - Continuous data streams with automatic reconnection\n\n### 🎨 Decorator Patterns\n\n- **Declarative Services** - Clean, maintainable API service layers using TypeScript decorators\n- **Metadata Extensions** - Custom metadata for advanced use cases\n- **Type-Safe APIs** - Full TypeScript integration with automatic type inference\n\n### 🎯 Event Bus Patterns\n\n- **Cross-Tab Communication** - Seamless event broadcasting between browser tabs\n- **Typed Event Handling** - Type-safe event management with priority ordering\n- **Async Event Processing** - Support for both synchronous and asynchronous event handlers\n\n## 🏗️ Development \u0026 Contributing\n\n### 🛠️ Prerequisites\n\n- Node.js \u003e= 16\n- pnpm \u003e= 8\n\n### 🚀 Development Commands\n\n```shell\n# Install dependencies\npnpm install\n\n# Build all packages\npnpm build\n\n# Run unit tests with coverage\npnpm test:unit\n\n# Format code\npnpm format\n\n# Clean build artifacts\npnpm clean\n\n# Run integration tests\n#pnpm test:it\n```\n\n### 📦 Version Management\n\nUpdate all packages simultaneously:\n\n```shell\npnpm update-version \u003cnew-version\u003e\n```\n\nThis updates the version field in all `package.json` files across the monorepo.\n\n### 🤝 Contributing\n\nWe welcome contributions! Please see our [contributing guide](./CONTRIBUTING.md) for details:\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a pull request\n\n### 🧪 Quality Assurance\n\n- **Code Coverage**: Maintained above 95% across all packages\n- **TypeScript**: Strict type checking enabled\n- **Linting**: ESLint with Prettier for consistent code style\n- **Testing**: Comprehensive unit and integration tests\n\n## 📄 License\n\nThis project is licensed under the [Apache-2.0 License](./LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahoo-wang%2Ffetcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahoo-wang%2Ffetcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahoo-wang%2Ffetcher/lists"}