{"id":21618851,"url":"https://github.com/bugs5382/fastify-rabbitmq","last_synced_at":"2025-04-11T08:42:26.363Z","repository":{"id":185906116,"uuid":"674214255","full_name":"Bugs5382/fastify-rabbitmq","owner":"Bugs5382","description":"A Fastify RabbitMQ Plugin Developed in Pure TypeScript using the AMQPLIB","archived":false,"fork":false,"pushed_at":"2025-03-25T00:42:36.000Z","size":273,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T00:51:27.902Z","etag":null,"topics":["fastify","fastify-plugin","rabbitmq","typescript"],"latest_commit_sha":null,"homepage":"","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/Bugs5382.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-03T11:59:39.000Z","updated_at":"2025-03-25T00:42:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"fe07fc22-f42f-41d1-a696-a844a1d35f29","html_url":"https://github.com/Bugs5382/fastify-rabbitmq","commit_stats":null,"previous_names":["bugs5382/fastify-rabbitmq"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bugs5382%2Ffastify-rabbitmq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bugs5382%2Ffastify-rabbitmq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bugs5382%2Ffastify-rabbitmq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bugs5382%2Ffastify-rabbitmq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bugs5382","download_url":"https://codeload.github.com/Bugs5382/fastify-rabbitmq/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248362476,"owners_count":21091137,"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":["fastify","fastify-plugin","rabbitmq","typescript"],"created_at":"2024-11-24T23:07:09.711Z","updated_at":"2025-04-11T08:42:26.343Z","avatar_url":"https://github.com/Bugs5382.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fastify RabbitMQ\n\nA Fastify RabbitMQ Plugin Developed in Pure TypeScript.\nIt uses the [node-rabbitmq-client](https://github.com/cody-greene/node-rabbitmq-client/) plugin as a wrapper.\n\nThe build exports this to valid ESM and CJS for ease of cross-compatibility.\n\nIf you are using this NPM package, please consider giving it a :star: star.\nThis will increase its visibility and solicit more contribution from the outside.\n\n## Table of Contents\n\n1. [Install](#install)\n2. [Basic Usage](#basic-usage)\n3. [Full Documentation](#full-documentation)\n   1. [Options](#options)\n4. [Acknowledgements](#acknowledgements)\n5. [License](#license)\n\n## Install\n\n```\nnpm install fastify-rabbitmq\n```\n\n## Basic Usage\n\nRegister this as a plugin.\nMake sure it is loaded before any **_routes_** are loaded.\n\n### Quick Setup on the Server Side\n\n```typescript\nexport default fp\u003cFastifyRabbitMQOptions\u003e((fastify, options, done) =\u003e {\n  void fastify.register(fastifyRabbit, {\n    connection: `amqp://guest:guest@localhost`,\n  });\n\n  void fastify.ready().then(async () =\u003e {\n    const consumer = fastify.rabbitmq.createConsumer(\n      {\n        queue: \"foo\",\n        queueOptions: { durable: true },\n      },\n      async (msg: any) =\u003e {\n        console.log(msg); // ==\u003e bar\n      },\n    );\n  });\n});\n```\n\n### Quick Setup on the Client Side\n\nWithin any \"endpoint\" function, or if you have access to `fastify.rabbitmq` you can then call:\n\n```js\nfastify.get(\"/rabbitmq\", async (request, reply) =\u003e {\n  let pub = request.rabbitmq.createPublisher({\n    confirm: true,\n    maxAttempts: 1,\n  });\n\n  await pub.send(\"foo\", \"bar\"); // ==\u003e sent to foo queue\n});\n```\n\nSending the string `bar` to the queue called `foo`.\n\n## Full Documentation\n\n### Options\n\n```typescript\nexport interface FastifyRabbitMQOptions {\n  /** Connection String or object pointing to the RabbitMQ Broker Services */\n  connection: string | ConnectionOptions;\n  /** To set the custom nNamespace within this plugin instance. Used to register this plugin more than one time. */\n  namespace?: string;\n}\n```\n\n#### FastifyRabbitMQOptions\n\n##### `connection`\n\nConnection String or object pointing to the RabbitMQ Broker Services.\nThis can be an object of `ConnectionOptions` from the `node-rabbitmq-client` plugin options.\n\n##### `namespace`\n\nIf you need more than one \"connection\" to a different set and/or array of RabbitMQ servers,\neither on network or cloud, each registration of the plugin needs it to be in its own namespace.\nIf the name space is duplicated, it will fail to load.\n\n## Acknowledgements\n\n- [node-rabbitmq-client](https://www.npmjs.com/package/rabbitmq-client)\n- [fastify](https://fastify.dev/)\n- ... and my Wife and Baby Girl.\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugs5382%2Ffastify-rabbitmq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbugs5382%2Ffastify-rabbitmq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbugs5382%2Ffastify-rabbitmq/lists"}