This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a TypeScript monorepo for HTTP Service - a unified HTTP request library for browser and server environments. Uses pnpm workspaces with the following key packages:
packages/http-svc/- Main HTTP service librarypackages/middleware/- Base middleware interfacespackages/server-fetch/- Server-side fetch implementationpackages/xhr/- XHR-based middlewaredocs/- VitePress documentationserver/- Test server (Koa-based)
pnpm start- Interactive package selector for running dev scriptspnpm dev- Run development server for selected packagepnpm build- Build selected package
pnpm test- Run Jest tests (from/packages/http-svc/)pnpm build- Dual build (modern ES2018+ and legacy ES2015+)pnpm build:modern- Modern ES build onlypnpm build:legacy- Legacy ES2015 build only- Tests run automatically before build (
prebuildhook)
pnpm docs:dev- Start VitePress development serverpnpm docs:build- Build documentation site
pnpm create- Create new packagespnpm pub- Interactive publishing workflow
The HTTP Service follows a middleware-based request pipeline pattern similar to Koa.js:
- HttpService (
/packages/http-svc/src/core.ts) - Main service class with three control units:AssembleControl- Middleware assembly and dispatchConfigControl- Per-request configuration contextRequestControl- Request execution management
Located in /packages/http-svc/src/built-in/:
HttpSvcFetch- Core fetch implementationHttpSvcSpray- Request optimizationHttpSvcRetry- Retry logicHttpSvcCache- Caching mechanismHttpSvcXsrf- CSRF protection- Plus utility middlewares for timeout, body processing, logging
- Fetch API-based core with fallback to XHR
- Dual environment support (browser/Node.js)
- TypeScript-first with comprehensive type definitions
- Extensible middleware system
- Dual module builds (ESM/CJS)
- Build Tool: Vite with dual-target configuration
- Output: Modern (.mjs) and legacy (.cjs) builds for maximum compatibility
- TypeScript: Strict mode enabled with comprehensive type checking
- Module Formats: Both ESM and CommonJS supported
- Framework: Jest with ts-jest preset
- Location:
/packages/http-svc/src/__tests__/ - Pattern:
**/*.spec.ts - Config:
packages/http-svc/jest.config.ts - Run tests with
pnpm testin the http-svc package - Run specific test:
pnpm test -- --testNamePattern="test name"
- ESLint: TypeScript configuration with Prettier integration (
.eslintrc.js) - Line Length: 140 characters maximum
- Formatting: Prettier for consistent code style
- No explicit lint/format scripts - integrated into development workflow