{"id":22884821,"url":"https://github.com/bewinxed/hooktuah","last_synced_at":"2025-03-31T17:53:34.156Z","repository":{"id":266412425,"uuid":"898260537","full_name":"Bewinxed/hooktuah","owner":"Bewinxed","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-04T11:00:01.000Z","size":65,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-06T22:42:11.841Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Bewinxed.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-12-04T04:36:05.000Z","updated_at":"2024-12-04T11:00:05.000Z","dependencies_parsed_at":"2024-12-04T06:27:27.863Z","dependency_job_id":"4ae840f7-4f4f-46e6-a5ee-d06619b90732","html_url":"https://github.com/Bewinxed/hooktuah","commit_stats":null,"previous_names":["bewinxed/hooktuah"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bewinxed%2Fhooktuah","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bewinxed%2Fhooktuah/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bewinxed%2Fhooktuah/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bewinxed%2Fhooktuah/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bewinxed","download_url":"https://codeload.github.com/Bewinxed/hooktuah/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246514038,"owners_count":20790013,"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":[],"created_at":"2024-12-13T19:28:56.958Z","updated_at":"2025-03-31T17:53:34.149Z","avatar_url":"https://github.com/Bewinxed.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🪝 HookTuah\n*\"Forward to that thang~!\"*\n\n[![npm version](https://img.shields.io/npm/v/hooktuah.svg)](https://www.npmjs.com/package/hooktuah)\n[![License](https://img.shields.io/npm/l/hooktuah.svg)](https://github.com/bewinxed/hooktuah/blob/main/LICENSE)\n[![Downloads](https://img.shields.io/npm/dm/hooktuah.svg)](https://www.npmjs.com/package/hooktuah)\n[![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)\n[![Bun](https://img.shields.io/badge/Bun-Compatible-black)](https://bun.sh)\n\nI was building a price tracking service, Some services I was using did not offer webhooks as a feature, And some did not have a Websocket connection, This library allows you to turn any event source and post it to a webhook endpoint.\n\n## 🌟 Features\n\n- 📡 Multiple event source types supported:\n  - WebSocket connections\n  - HTTP polling with customizable intervals\n  - Custom event streams\n- 🔄 Automatic retry mechanisms for connection failures\n- 🎯 Event transformation and filtering\n- 💪 Type-safe with full TypeScript support\n- 🧪 Comprehensive test coverage\n- 🔌 Easy to integrate with existing systems\n\n## 📦 Installation\n\n```bash\n# Using npm\nnpm install hooktuah\n\n# Using yarn\nyarn add hooktuah\n\n# Using bun\nbun add hooktuah\n```\n\n## 🚀 Quick Start\n\n```typescript\nimport { EventForwarder } from 'hooktuah';\n\n// Create a new forwarder instance\nconst forwarder = new EventForwarder\u003cRequestType, InputType, OutputType\u003e();\n\n// Subscribe to events\nforwarder.subscribe('my-source', {\n  type: 'websocket',\n  sourceUrl: 'wss://my-source.com/events',\n  webhookUrl: 'https://my-webhook.com/endpoint',\n  transform: (data) =\u003e {\n    // Transform your data before forwarding\n    return transformedData;\n  }\n});\n```\n\n## 📖 Usage Examples\n\n### WebSocket Source\n\n```typescript\nconst forwarder = new EventForwarder\u003cvoid, SensorData, TransformedData\u003e();\n\nforwarder.subscribe('sensor-stream', {\n  type: 'websocket',\n  sourceUrl: 'wss://sensors.example.com/stream',\n  webhookUrl: 'https://api.example.com/webhook',\n  transform: (data) =\u003e ({\n    id: data.deviceId,\n    tempCelsius: data.temperature,\n    tempFahrenheit: (data.temperature * 9) / 5 + 32,\n    readingTime: new Date(data.timestamp).toISOString()\n  })\n});\n```\n\n### HTTP Polling\n\n```typescript\nforwarder.subscribe('api-poll', {\n  type: 'polling',\n  sourceUrl: 'https://api.example.com/data',\n  webhookUrl: 'https://webhook.site/your-endpoint',\n  pollInterval: 5000, // 5 seconds\n  shouldFetch: async () =\u003e {\n    // Conditionally fetch based on your requirements\n    return true;\n  }\n});\n```\n\n### Custom Event Stream\n\n```typescript\nforwarder.subscribe('custom-source', {\n  type: 'custom',\n  webhookUrl: 'https://your-webhook.com/endpoint',\n  createStream: async () =\u003e {\n    return new Observable((subscriber) =\u003e {\n      // Your custom event source logic here\n      return () =\u003e {\n        // Cleanup logic\n      };\n    });\n  }\n});\n```\n\n## 🔧 Configuration Options\n\nThe `ForwarderConfig` interface supports the following options:\n\n- `type`: 'websocket' | 'polling' | 'custom'\n- `sourceUrl`: URL for the event source\n- `webhookUrl`: Destination webhook URL\n- `transform`: Optional data transformation function\n- `pollInterval`: Required for polling sources\n- `shouldFetch`: Optional condition for processing events\n- `requestConfig`: Optional HTTP request configuration\n- `createStream`: Required for custom sources\n\n## 🧪 Testing\n\n```bash\n# Run tests\nbun test\n\n# Run tests with coverage\nbun test --coverage\n```\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## 📜 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- Built with [RxJS](https://rxjs.dev/)\n- Tested with [Bun](https://bun.sh)\n- Inspired by the need for robust event forwarding in modern applications\n\n---\n\nMade with ❤️ by Bewinxed\n\n*Don't forget to give this project a ⭐ if you found it helpful!*","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbewinxed%2Fhooktuah","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbewinxed%2Fhooktuah","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbewinxed%2Fhooktuah/lists"}