{"id":14969166,"url":"https://github.com/fastify/fastify-kafka","last_synced_at":"2025-04-04T22:02:28.150Z","repository":{"id":26618988,"uuid":"109397583","full_name":"fastify/fastify-kafka","owner":"fastify","description":"Fastify plugin to interact with Apache Kafka","archived":false,"fork":false,"pushed_at":"2025-03-28T06:41:37.000Z","size":123,"stargazers_count":60,"open_issues_count":2,"forks_count":20,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-03-28T21:07:17.460Z","etag":null,"topics":["event-sourcing","events","fastify","fastify-plugin","kafka"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/@fastify/kafka","language":"JavaScript","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/fastify.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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":"fastify","open_collective":"fastify"}},"created_at":"2017-11-03T13:16:58.000Z","updated_at":"2025-03-28T06:41:38.000Z","dependencies_parsed_at":"2023-01-14T05:02:45.039Z","dependency_job_id":"672731c6-e4ed-4efb-bbe7-536946e2ae02","html_url":"https://github.com/fastify/fastify-kafka","commit_stats":{"total_commits":106,"total_committers":18,"mean_commits":5.888888888888889,"dds":0.7264150943396226,"last_synced_commit":"79dcaaa79549767b39ccc4c42b619944b9300316"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-kafka","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-kafka/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-kafka/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastify%2Ffastify-kafka/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastify","download_url":"https://codeload.github.com/fastify/fastify-kafka/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256103,"owners_count":20909240,"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":["event-sourcing","events","fastify","fastify-plugin","kafka"],"created_at":"2024-09-24T13:41:15.756Z","updated_at":"2025-04-04T22:02:28.128Z","avatar_url":"https://github.com/fastify.png","language":"JavaScript","funding_links":["https://github.com/sponsors/fastify","https://opencollective.com/fastify"],"categories":["\u003ca name=\"JavaScript\"\u003e\u003c/a\u003eJavaScript"],"sub_categories":[],"readme":"# @fastify/kafka\n\n[![CI](https://github.com/fastify/fastify-kafka/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/fastify-kafka/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/@fastify/kafka.svg?style=flat)](https://www.npmjs.com/package/@fastify/kafka)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)\n\nFastify plugin to interact with [Apache Kafka](http://kafka.apache.org/), supporting Kafka producers and consumers.\nTo achieve the best performance, the plugin uses [`node-rdkafka`](https://github.com/Blizzard/node-rdkafka).\n\n### Install\n\n```\nnpm i @fastify/kafka\n```\n\n### Compatibility\n| Plugin version | Fastify version |\n| ---------------|-----------------|\n| `\u003e=3.x`        | `^5.x`          |\n| `\u003e=0.x \u003c3.x`   | `^4.x`          |\n| `\u003e=0.x \u003c3.x`   | `^3.x`          |\n| `\u003e=0.x \u003c3.x`   | `^2.x`          |\n| `\u003e=0.x \u003c3.x`   | `^1.x`          |\n\nPlease note that if a Fastify version is out of support, then so are the corresponding versions of this plugin\nin the table above.\nSee [Fastify's LTS policy](https://github.com/fastify/fastify/blob/main/docs/Reference/LTS.md) for more details.\n\n### Usage\n\n```js\nconst crypto = require('node:crypto')\nconst fastify = require('fastify')()\nconst group = crypto.randomBytes(20).toString('hex')\n\nfastify\n  .register(require('@fastify/kafka'), {\n    producer: {\n      'metadata.broker.list': '127.0.0.1:9092',\n      'fetch.wait.max.ms': 10,\n      'fetch.error.backoff.ms': 50,\n      'dr_cb': true\n    },\n    consumer: {\n      'metadata.broker.list': '127.0.0.1:9092',\n      'group.id': group,\n      'fetch.wait.max.ms': 10,\n      'fetch.error.backoff.ms': 50,\n      'auto.offset.reset': 'earliest'\n    }\n  })\n\nfastify.post('/data', (req, reply) =\u003e {\n  fastify.kafka.push({\n    topic: 'updates',\n    payload: req.body,\n    key: 'dataKey'\n  })\n})\n\nfastify.kafka.subscribe('updates')\nfastify.kafka.on('updates', (msg, commit) =\u003e {\n  console.log(msg.value.toString())\n  commit()\n})\n\nfastify.listen({ port: 3000 }, err =\u003e {\n  if (err) throw err\n  console.log(`server listening on ${fastify.server.address().port}`)\n})\n ```\n\nFor more examples on how to use this plugin, you can take a look at the [examples directory](./examples).\n\n### API\nThis module exposes the following APIs:\n##### Producer\n- `fastify.kafka.producer`: the producer instance\n- `fastify.kafka.push`: utility to produce a new message\n\n##### Consumer\n- `fastify.kafka.consumer`: the consumer instance\n- `fastify.kafka.consume`: utility to start the message consuming\n- `fastify.kafka.subscribe`: utility to begin subscribing to one or more topics\n- `fastify.kafka.on`: topic listener\n\n## Acknowledgments\n\nThis project is kindly sponsored by:\n- [LetzDoIt](https://www.letzdoitapp.com/)\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ffastify-kafka","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastify%2Ffastify-kafka","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastify%2Ffastify-kafka/lists"}