{"id":15861595,"url":"https://github.com/leroyanders/amqplib-rpc","last_synced_at":"2025-10-18T08:41:37.311Z","repository":{"id":158932080,"uuid":"612768054","full_name":"leroyanders/amqplib-rpc","owner":"leroyanders","description":"RabbitMQ RPC Helper","archived":false,"fork":false,"pushed_at":"2023-03-11T23:28:15.000Z","size":870,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-27T03:54:11.678Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/leroyanders.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":"2023-03-11T23:01:08.000Z","updated_at":"2025-03-17T14:22:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"fd87de9b-5372-4497-9604-13da9a7e0a68","html_url":"https://github.com/leroyanders/amqplib-rpc","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"3d4ff75fb5fe03a3522d5025f5ffd825ac969cd0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leroyanders/amqplib-rpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leroyanders%2Famqplib-rpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leroyanders%2Famqplib-rpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leroyanders%2Famqplib-rpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leroyanders%2Famqplib-rpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leroyanders","download_url":"https://codeload.github.com/leroyanders/amqplib-rpc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leroyanders%2Famqplib-rpc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274291361,"owners_count":25258156,"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","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-05T22:03:02.999Z","updated_at":"2025-10-18T08:41:37.221Z","avatar_url":"https://github.com/leroyanders.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RabbitMQ amqplib RPC helper class (Reply-to)\n## Instalation \n\n```bash\nnpm install amqplib\n```\n\n## Server side (Provider)\n\n```javascript\nconst Provider = require(\"./provider\")\n\nnew Provider({\n  queue: \"example4\",\n  \n  // this function will reply consumers messages\n  responseFn: async (message, reply) =\u003e {\n    switch (message) {\n        case \"command1\":\n            return \"Hi there!\";\n        break;\n        case \"command2\":\n            return {status: 200};\n        break;\n        default: \n            return {result: 404, reason: \"not found command.\"};\n        break;\n    }\n  },\n}).connect(\"amqp://localhost\");\n```\n\nNote you should use responseFn to reply the answer, if you don't wanna answer, just return nothing.\n\n## Client side (Consumer)\n\n```javascript\nconst Consumer = require(\"./consumer\")\n\nnew Consumer({\n  queue: \"example4\",\n}).then((client) =\u003e {\n  client\n    .connect(\"amqp://localhost\")\n    .then((client) =\u003e {\n      return client.send({ text: \"hello\" });\n    })\n    .then((response) =\u003e {\n      console.log(response);\n    });\n});\n```\n\n### Express.js example\n\n```bash\nnpm install express\n```\n\n```javascript\nconst express = require(\"express\");\nconst app = express();\nconst Consumer = require(\"./consumer\")\n\napp.get(\"/test\", async (req, res) =\u003e {\n    const client = await new Consumer({\n        queue: \"example4\"\n    });\n    \n    // Send message and receive the answer from provider\n    const response = await client.connect(\"amqp://localhost\")\n      .then((client) =\u003e client.send(\"hello\"))\n      .then(res);\n\n    res.send(response);\n})\n\napp.listen(3000, () =\u003e {\n  console.log(`Server is running on port 3000`);\n});\n```\n\n### Advanced parameters:\n\n- **queue**: *required.*, Set your queue.\n- **correlationId**: Set correlation ID for receiver.\n- **replyTo**: *required.* Client to receive reply from provider.\n- **contentType**: \"*application/json*\" or \"*application/textplain*\", it used for format message, in any case it will do automatically.\n- **responseType**: \"application/json\" or \"application/textplain\", it used for format message, in any case it will do automatically.\n- **connectionAdress**: Connection adress, for example: ```amqp://localhost/```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleroyanders%2Famqplib-rpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleroyanders%2Famqplib-rpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleroyanders%2Famqplib-rpc/lists"}