request-client/
├── .github/ # GitHub-specific files
│ ├── ISSUE_TEMPLATE/ # Issue templates
│ │ ├── bug_report.md
│ │ └── feature_request.md
│ ├── workflows/ # GitHub Actions workflows
│ │ ├── ci.yml # Continuous Integration
│ │ ├── publish.yml # JSR Publishing
│ │ ├── quality.yml # Quality checks
│ │ └── release-drafter.yml
│ ├── PULL_REQUEST_TEMPLATE.md
│ └── release-drafter-config.yml
│
├── .vscode/ # VS Code configuration
│ ├── extensions.json # Recommended extensions
│ └── settings.json # Workspace settings
│
├── coverage/ # Test coverage reports
│ ├── html/ # HTML coverage reports
│ └── lcov.info # LCOV format for CI
│
├── examples/ # Usage examples
│ ├── basic.ts
│ └── interceptors.ts
│
├── packages/ # Workspace packages
│ ├── deno.json # Package-specific config
│ ├── client/ # Request client package
│ │ ├── spec/ # Test specifications
│ │ │ ├── request.client.spec.ts
│ │ │ └── request.client.test.ts
│ │ └── src/ # Source code
│ │ ├── interceptors.ts # Interceptor management
│ │ ├── mod.ts # Public API exports
│ │ ├── request.client.ts # Main RequestClient class
│ │ └── types.ts # Type definitions
│ └── utils/ # Utility packages
│ ├── spec/
│ └── src/
│ ├── mock.helper.ts # Test utilities
│ └── mod.ts
│
├── .editorconfig # Editor configuration
├── .gitignore # Git ignore rules
├── ARCHITECTURE.md # Architecture documentation
├── CODE_OF_CONDUCT.md # Community guidelines
├── CONTRIBUTING.md # Contribution guide
├── LICENSE # Apache-2.0 License
├── README.md # Project documentation
├── SECURITY.md # Security policy
├── deno.json # Deno workspace configuration
└── jsr.json # JSR package config
The main class that provides an axios-style interface for making HTTP requests.
Key Features:
- Configuration management (baseURL, headers, timeout)
- HTTP method wrappers (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS)
- Interceptor support
- URL building with query parameters
- Response type handling
- Timeout management
- Error handling
Type definitions for the request client:
RequestConfig- Configuration optionsRequestResponse<T>- Response structureRequestError- Custom error class
Manages request, response, and error interceptors:
RequestInterceptor- Modify requests before sendingResponseInterceptor- Transform responsesErrorInterceptor- Handle errorsInterceptorManager- Manage interceptor lifecycle
Utility functions for testing:
- Mock helpers for testing HTTP requests
- Test utilities for interceptors
User Code
↓
RequestClient Method (get, post, etc.)
↓
Request Interceptors
↓
Build URL & Headers
↓
Native Fetch API
↓
Response Interceptors
↓
Process Response
↓
Return RequestResponse
Error Occurs
↓
Create RequestError
↓
Error Interceptors
↓
Throw to User Code
Tests are organized in the packages/client/spec/ directory with two types of test files:
*.test.ts- Unit tests (run withdeno task test:unit)*.spec.ts- Specification tests (run withdeno task test:spec)
Test Coverage:
- Unit tests for all public methods
- HTTP method tests (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS)
- Configuration tests
- Interceptor tests
- Error handling tests
- Timeout tests
- Coverage reports generated in
coverage/directory - LCOV format reports for CI integration
Runs on push to main and pull requests:
- Lint Check - Code style validation with Deno lint
- Format Check - Code formatting validation
- Type Check - TypeScript type validation
- Unit Tests - Run test suite with coverage
- Coverage Upload - Upload to Codecov
- Test Matrix - Multi-platform testing (Ubuntu, macOS, Windows) with Deno v1.x and v2.x
Triggers on release or manual dispatch:
- Run unit tests
- Run linting
- Run format check
- Dry-run option for testing
- Publish to JSR with proper permissions (id-token: write)
Runs on pull requests:
- Dependency Review - Check for vulnerable dependencies
- TODO/FIXME Detection - Detect unresolved comments
Automatically drafts releases based on merged PRs and labels
Main Deno workspace configuration:
- Workspace: Monorepo setup with
./packages - Lint: Includes
packages/, excludes.github/,README.md,build/,coverage/ - Format: Single quotes, 2-space indentation, 80 character line width
- Tasks:
check- Type checkingtest:unit- Run unit tests with coveragetest:spec- Run specification teststest:watch- Watch mode for testslint- Run linterfmt- Format codefmt:check- Check formattingcoverage- Generate LCOV coverage report
- Permissions: Network access to
jsonplaceholder.typicode.comfor tests - Imports: Test dependencies from JSR
@c4spar/mock-fetch- Mock fetch for testing@std/assert- Assertions@std/testing- Testing utilities
JSR package metadata:
- Package name:
@anitrend/request-client - Version:
0.1.0 - Exports:
./packages/client/src/mod.ts
- Setup: Install Deno 2.x or higher
- Branch: Create a feature branch following naming conventions:
feat/<feature-name>- New featuresfix/<bug-name>- Bug fixeschore/<task-name>- Enhancementsrefactor/<name>- Code refactoringbuild/<name>- Dependenciestest/<name>- Testingci/<name>- CI/CD changesdocs/<name>- Documentationrevert/<name>- Reverts
- Development: Make changes in
packages/client/src/ - Testing:
deno task test:unit- Run unit testsdeno task test:spec- Run spec testsdeno task test:watch- Watch mode
- Linting:
deno task lint - Formatting:
deno task fmtordeno task fmt:check - Type Check:
deno task check - Coverage:
deno task coverage - Commit: Follow conventional commits
- PR: Create pull request with proper labels
- Review: Automated checks + manual review
- Merge: Merge to main
- Release: Automated release draft created
- Publish: Publish to JSR on release
- Modern JavaScript/TypeScript runtime
- Native TypeScript support
- Secure by default
- Standard library
- Built-in tooling (fmt, lint, test)
- Familiar to developers
- Intuitive method names
- Flexible configuration
- Interceptor pattern
- Smaller package size
- Faster installation
- Fewer security vulnerabilities
- Easier maintenance
- Better performance
- Modern package registry for TypeScript
- Native Deno support
- Better documentation
- Faster publishing
- Improved developer experience