{"id":20375127,"url":"https://github.com/hebertcisco/nestjs-undici","last_synced_at":"2026-03-15T06:23:55.913Z","repository":{"id":57701762,"uuid":"507692825","full_name":"hebertcisco/nestjs-undici","owner":"hebertcisco","description":"Undici utilities module based on the @nodejs undici package 🌐https://www.npmjs.com/package/nestjs-undici","archived":false,"fork":false,"pushed_at":"2025-03-17T16:32:11.000Z","size":1788,"stargazers_count":15,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T07:17:40.426Z","etag":null,"topics":["nest","nestjs","nestjs-module","typescript","undici"],"latest_commit_sha":null,"homepage":"https://hebertcisco.github.io/nestjs-undici/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hebertcisco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["hebertcisco"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2022-06-26T21:55:41.000Z","updated_at":"2025-04-09T10:21:52.000Z","dependencies_parsed_at":"2023-02-16T13:31:13.666Z","dependency_job_id":"badb12ae-836e-4987-83dc-fa7d35164286","html_url":"https://github.com/hebertcisco/nestjs-undici","commit_stats":{"total_commits":134,"total_committers":4,"mean_commits":33.5,"dds":0.4776119402985075,"last_synced_commit":"c12e0378d43a0197efd590e4254204d15776e33d"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hebertcisco%2Fnestjs-undici","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hebertcisco%2Fnestjs-undici/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hebertcisco%2Fnestjs-undici/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hebertcisco%2Fnestjs-undici/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hebertcisco","download_url":"https://codeload.github.com/hebertcisco/nestjs-undici/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248530604,"owners_count":21119601,"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":["nest","nestjs","nestjs-module","typescript","undici"],"created_at":"2024-11-15T01:28:55.298Z","updated_at":"2026-03-15T06:23:55.907Z","avatar_url":"https://github.com/hebertcisco.png","language":"TypeScript","funding_links":["https://github.com/sponsors/hebertcisco"],"categories":[],"sub_categories":[],"readme":"# NestJS Undici\n\n[![npm version](https://badge.fury.io/js/nestjs-undici.svg)](https://badge.fury.io/js/nestjs-undici)\n[![Running Code Coverage](https://github.com/hebertcisco/nestjs-undici/actions/workflows/coverage.yml/badge.svg)](https://github.com/hebertcisco/nestjs-undici/actions/workflows/coverage.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n**NestJS Undici** is a powerful HTTP client module for NestJS applications, built on top of [@nodejs/undici](https://github.com/nodejs/undici). It provides a simple and efficient way to make HTTP requests in your NestJS applications.\n\n## Features\n\n- 🚀 Built on top of [@nodejs/undici](https://github.com/nodejs/undici)\n- 🔄 Full TypeScript support\n- ⚡ High-performance HTTP client\n- 🔒 Secure by default\n- 🛠️ Easy to configure and use\n- 📦 Lightweight and dependency-free\n- 📝 Comprehensive documentation\n\n## Installation\n\n```bash\n# Using npm\nnpm install nestjs-undici\n\n# Using yarn\nyarn add nestjs-undici\n```\n\n## Quick Start\n\n1. Import the `HttpModule` in your root module:\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { HttpModule } from 'nestjs-undici';\n\n@Module({\n  imports: [\n    HttpModule.register({\n      // Optional configuration (Undici Request Options)\n      headers: {\n        'User-Agent': 'NestJS-Undici',\n      },\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n2. Inject and use the `HttpService` in your service:\n\n```typescript\nimport { Injectable } from '@nestjs/common';\nimport { HttpService } from 'nestjs-undici';\nimport { lastValueFrom } from 'rxjs';\n\n@Injectable()\nexport class AppService {\n  constructor(private readonly httpService: HttpService) {}\n\n  async getUsers() {\n    const response = await lastValueFrom(\n      this.httpService.request('https://api.example.com/users')\n    );\n    \n    return response.body.json();\n  }\n}\n```\n\n## Configuration\n\nThe `HttpModule` can be configured using the `register` or `registerAsync` methods. The configuration object accepts standard [Undici Request Options](https://github.com/nodejs/undici#undicirequesturl-options-promise) and an optional `dispatcher`.\n\n### Synchronous Configuration\n\n```typescript\nimport { Agent } from 'undici';\n\nHttpModule.register({\n  headers: {\n    'Content-Type': 'application/json',\n  },\n  // You can set a custom dispatcher (e.g., for proxy or mocking)\n  dispatcher: new Agent({\n    connect: {\n      timeout: 5000\n    }\n  }),\n});\n```\n\n### Asynchronous Configuration\n\n```typescript\nHttpModule.registerAsync({\n  useFactory: async (configService: ConfigService) =\u003e ({\n    headers: {\n      'Authorization': await configService.get('API_KEY'),\n    },\n  }),\n  inject: [ConfigService],\n});\n```\n\n## Advanced Usage\n\n### Making HTTP Requests\n\n```typescript\n// POST request\nconst response = await lastValueFrom(\n  this.httpService.request('https://api.example.com/users', {\n    method: 'POST',\n    body: JSON.stringify({ name: 'John Doe' }),\n  })\n);\n```\n\n### Using Custom Dispatchers (Interception)\n\nTo intercept requests or configure advanced behavior (like connection pools, proxies, or mocks), use a custom Dispatcher.\n\n```typescript\nimport { Injectable } from '@nestjs/common';\nimport { HttpService } from 'nestjs-undici';\nimport { ProxyAgent } from 'undici';\n\n@Injectable()\nexport class AppService {\n  constructor(private readonly httpService: HttpService) {\n    // Set a global dispatcher for this service instance\n    this.httpService.setGlobalDispatcher(new ProxyAgent('http://my-proxy:8080'));\n  }\n}\n```\n\n## API Reference\n\nFor detailed API documentation, please visit our [documentation site](https://hebertcisco.github.io/nestjs-undici/).\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\nIf you find this package useful, please consider giving it a ⭐️ on [GitHub](https://github.com/hebertcisco/nestjs-undici).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhebertcisco%2Fnestjs-undici","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhebertcisco%2Fnestjs-undici","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhebertcisco%2Fnestjs-undici/lists"}