trembita-http-client

Category: Development & Coding | Uploader: oleg-kovaloleg-koval | Downloads: 0 | Version: v1.0(Latest)

Build resilient, type-safe HTTP integrations with trembita using Result-based error handling, retries, and circuit breaker patterns. --- # Trembita Skill Use this repository as a practical reference for agents implementing HTTP clients with `trembita`. ## When to Use - Build TypeScript integrations for third-party REST APIs. - Add robust error handling without exception-driven control flow. - Implement retries, circuit breakers, and timeouts with minimal dependencies. - Write testable API code by injecting `fetchImpl`. ## Core Patterns 1. Initialize once with `createTrembita()` and handle init `Result`. 2. Use `client.request()` for parsed JSON body responses. 3. Use `client.client()` when you need HTTP metadata (`statusCode`, `body`). 4. Narrow failures by checking `result.error.kind`. 5. Add resilience via `createRetryingFetch` and `circuitBreaker` config. ## Canonical References - `README.md` - quick overview and install. - `QUICK_START.md` - shortest path to first success. - `LEARNING_GUIDE.md` - concepts and progressive examples. - `EXAMPLES.md` - production-style patterns. - `ARCHITECTURE.md` - request/error flow diagrams. ## Agent Guardrails - Prefer `Result` handling over `try/catch` for request outcomes. - Keep endpoint configuration explicit and validated. - Prefer `expectedCodes` to document acceptable HTTP outcomes. - Use `client.client()` for 404/202 branching by status code. - Inject `fetchImpl` in tests; avoid global fetch patching.

Changelog: Source: GitHub https://github.com/oleg-koval/trembita

Directory Structure

Current level: tree/main/

  • 📁 .github/
    • 📁 ISSUE_TEMPLATE/
      • 📄 BUG.md 185 B
    • 📁 workflows/
      • 📄 automerge.yml 604 B
      • 📄 code-quality.yml 1.5 KB
      • 📄 codeql-analysis.yml 813 B
      • 📄 merge-me.yml 654 B
      • 📄 npm-release.yml 1.3 KB
      • 📄 pages.yml 750 B
    • 📄 dependabot.yml 504 B
  • 📁 assets/
    • 📄 banner.png 137.7 KB
  • 📁 docs/
    • 📄 SKILL_DEFINITION.md 4.3 KB
  • 📁 examples/
    • 📁 openapi-dogfood/
      • 📄 main.mjs 1.4 KB
      • 📄 package.json 311 B
    • 📄 agent-examples.ts 13.7 KB
    • 📄 README.md 5.6 KB
    • 📄 resilience-patterns.ts 11.0 KB
    • 📄 rest-api-client.ts 5.4 KB
    • 📄 testing-with-mock-fetch.test.ts 7.1 KB
  • 📁 packages/
    • 📁 openapi/
      • 📁 fixtures/
        • 📄 mini-api.openapi.yaml 1.1 KB
        • 📄 mini-api.paths.ts 2.4 KB
      • 📁 scripts/
        • 📄 spike-bundle-metrics.mjs 976 B
      • 📁 src/
        • 📄 expandPath.ts 1009 B
        • 📄 index.ts 504 B
        • 📄 requestOpenapiPath.ts 911 B
      • 📁 test/
        • 📄 expandPath.test.ts 600 B
        • 📄 paths-spike.test.ts 938 B
        • 📄 requestOpenapiPath.test.ts 1.8 KB
      • 📄 eslint.config.js 818 B
      • 📄 package.json 1.4 KB
      • 📄 README.md 5.5 KB
      • 📄 tsconfig.json 430 B
      • 📄 vitest.config.ts 382 B
  • 📁 scripts/
    • 📄 check-openapi-fetch-types.mjs 990 B
    • 📄 patch-npm-vendored.mjs 1.2 KB
  • 📁 src/
    • 📄 constants.ts 201 B
    • 📄 errors.ts 1.2 KB
    • 📄 index.ts 917 B
    • 📄 requestWithStandardSchema.ts 810 B
    • 📄 result.ts 288 B
    • 📄 retryingFetch.ts 2.9 KB
    • 📄 standardSchema.ts 2.9 KB
    • 📄 tracing.ts 417 B
    • 📄 trembita.ts 9.9 KB
    • 📄 url.ts 1.1 KB
    • 📄 validate.ts 2.8 KB
  • 📁 test/
    • 📁 responses/
      • 📄 get-users-page-2.json 336 B
    • 📄 browser-smoke.test.ts 495 B
    • 📄 npm-release-workflow.test.ts 8.2 KB
    • 📄 npm-release.workflow.test.ts 1.7 KB
    • 📄 requestWithStandardSchema.test.ts 3.0 KB
    • 📄 retryingFetch.test.ts 4.7 KB
    • 📄 standardSchema.test.ts 5.0 KB
    • 📄 tracing.test.ts 964 B
    • 📄 trembita.test.ts 28.3 KB
  • 📄 .gitignore 477 B
  • 📄 .prettierignore 173 B
  • 📄 .prettierrc.yml 60 B
  • 📄 .releaserc.yaml 458 B
  • 📄 _config.yml 28 B
  • 📄 AGENT_CHECKLIST.md 9.9 KB
  • 📄 AGENT_GUIDE.md 12.6 KB
  • 📄 ARCHITECTURE.md 15.0 KB
  • 📄 CHANGELOG.md 27.4 KB
  • 📄 CLAUDE.md 3.1 KB
  • 📄 CONTRIBUTING.md 4.1 KB
  • 📄 DECISION_GUIDE.md 11.1 KB
  • 📄 DISCOVERY.md 10.4 KB
  • 📄 eslint.config.js 842 B
  • 📄 EXAMPLES.md 16.4 KB
  • 📄 LEARNING_GUIDE.md 13.1 KB
  • 📄 LICENSE 1.1 KB
  • 📄 package-lock.json 333.4 KB
  • 📄 package.json 2.7 KB
  • 📄 QUICK_START.md 4.2 KB
  • 📄 README.md 17.1 KB
  • 📄 SKILL.md 1.5 KB
  • 📄 SKILL_SUMMARY.md 9.6 KB
  • 📄 SPEC.md 10.7 KB
  • 📄 tsconfig.json 595 B
  • 📄 typedoc.json 234 B
  • 📄 vitest.config.ts 540 B

SKILL.md

Login to download/like/favorite ❤ 13 | ★ 0
Comments 0

Please login before commenting.

Loading comments...