{"id":22779435,"url":"https://github.com/mccann-hub/service-agent","last_synced_at":"2026-02-17T13:04:57.678Z","repository":{"id":264864397,"uuid":"892678130","full_name":"McCann-Hub/service-agent","owner":"McCann-Hub","description":"Custom Axios client for microservice debugging and tracing. Automatically injects correlation IDs, trace IDs, and span IDs into HTTP headers, enhancing observability across distributed systems","archived":false,"fork":false,"pushed_at":"2025-03-27T14:06:39.000Z","size":180,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T06:20:23.320Z","etag":null,"topics":["axios","deno","deno-module","microservices","typescript","typescript-library"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/McCann-Hub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-11-22T15:08:49.000Z","updated_at":"2024-12-16T23:22:17.000Z","dependencies_parsed_at":"2025-02-05T15:48:54.719Z","dependency_job_id":"ce3d8da9-3b1c-4205-a704-96d001c1525a","html_url":"https://github.com/McCann-Hub/service-agent","commit_stats":null,"previous_names":["mccann-hub/service-agent"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/McCann-Hub%2Fservice-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/McCann-Hub%2Fservice-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/McCann-Hub%2Fservice-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/McCann-Hub%2Fservice-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/McCann-Hub","download_url":"https://codeload.github.com/McCann-Hub/service-agent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248695303,"owners_count":21146952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["axios","deno","deno-module","microservices","typescript","typescript-library"],"created_at":"2024-12-11T20:08:48.107Z","updated_at":"2026-02-17T13:04:52.638Z","avatar_url":"https://github.com/McCann-Hub.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Service Agent\n\nA custom Axios client for streamlined debugging and tracing in distributed microservices environments. This library facilitates the propagation of correlation IDs, trace IDs, and span IDs across service boundaries, enhancing observability and troubleshooting.\n\n## Features\n\n- Automatic injection of `correlationId`, `traceId`, and `spanId` into HTTP headers.\n- Customizable span ID generation for service-to-service calls.\n- Robust logging for request and response lifecycles.\n- Extendable via custom Axios configurations.\n\n## Installation\n\n```bash\nnpm install @mccann-hub/service-agent\n```\n\nor\n\n```bash\nyarn add @mccann-hub/service-agent\n```\n\n## Usage\n\n### Basic Setup\n\n```typescript\nimport serviceAgent from \"@mccann-hub/service-agent\";\n\nconst req = {\n  correlationId: \"abc123\",\n  traceId: \"xyz789\",\n  logger: console,\n};\n\nconst client = serviceAgent()(req);\n\nclient\n  .get(\"/endpoint\")\n  .then((response) =\u003e console.log(response.data))\n  .catch((err) =\u003e console.error(err));\n```\n\n### Custom Configurations\n\n```typescript\nconst client = serviceAgent({\n  correlationIdHeader: \"X-Correlation-Id\",\n  traceIdHeader: \"X-Trace-Id\",\n  spanIdHeader: \"X-Span-Id\",\n  axiosConfig: {\n    baseURL: \"https://api.example.com\",\n    timeout: 5000,\n  },\n})(req);\n```\n\n### Integration with Express\n\n```typescript\nimport express from \"express\";\nimport serviceAgent from \"@mccann-hub/service-agent\";\n\nconst app = express();\n\napp.get(\"/api\", (req, res) =\u003e {\n  const client = serviceAgent()(req);\n  client\n    .get(\"/other-service\")\n    .then((data) =\u003e res.send(data))\n    .catch((err) =\u003e res.status(500).send(err.message));\n});\n```\n\n## API\n\n### serviceAgent(config?)\n\n- **config (optional):** Configuration object:\n  - **correlationIdHeader:** Header name for correlation IDs (default: X-Correlation-Id).\n  - **traceIdHeader:** Header name for trace IDs (default: X-Request-Id).\n  - **spanIdHeader:** Header name for span IDs (default: X-svc2svc-Id).\n  - **generator:** Function to generate span IDs.\n  - **axiosConfig:** Custom Axios configuration.\n\nReturns a function that accepts an IRequest object and returns an Axios instance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmccann-hub%2Fservice-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmccann-hub%2Fservice-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmccann-hub%2Fservice-agent/lists"}