{"_id":"@bashleigh/nestjs-amqp","_rev":"5-8a9dcfdcf94c1521d1bef521589c3a74","time":{"0.0.1":"2018-07-04T16:49:41.914Z","created":"2018-07-10T10:37:10.673Z","0.0.2":"2018-07-10T10:37:11.016Z","modified":"2022-06-12T15:02:46.957Z"},"name":"@bashleigh/nestjs-amqp","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.2":{"name":"@bashleigh/nestjs-amqp","description":"RabbitMQ service for nestjs","keywords":["nestjs","amqp"],"main":"dist/index.js","version":"0.0.2","license":"MIT","devDependencies":{"@types/es6-promise":"^3.3.0","@types/node":"^10.5.1","prettier":"^1.13.7","typescript":"^2.9.2"},"dependencies":{"@bashleigh/nest-config":"^0.1.4","@nestjs/common":"^5.0.1","amqplib":"^0.5.2","bluebird":"^3.5.1","reflect-metadata":"^0.1.12","rxjs":"^6.2.1"},"scripts":{"format":"prettier --write \"**/*.ts\"","test":"echo 'no tests'","prepublish":"rm -rf dist && tsc"},"repository":{"type":"git","url":"https://github.com/bashleigh/nestjs-amqp.git"},"licenseText":"MIT License\n\nCopyright (c) 2018 Ashleigh Simonelli\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@bashleigh/nestjs-amqp@0.0.2","dist":{"shasum":"5c680b2b6cabc7e8ce043977ebf76f8fe3cfb9ba","tarball":"https://registry.npmjs.org/@bashleigh/nestjs-amqp/-/nestjs-amqp-0.0.2.tgz","fileCount":28,"unpackedSize":12214,"integrity":"sha512-9g5YXs+NK6mUCUQVqWXO+AMuh18stpCQDBJcXx/NaUHRZhzm4M2kHU1nrmzSysXAQlkKol2j6Vw/eKl322UWDA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDiTM0BX4veDCrvtuxf2ChC6Hi3hYVy3/MvOi+qgLgcHAiBSx5UlYN02LzyLDbomi5jRqduP+riBWBCN38/tclOA1w=="}]},"maintainers":[{"name":"bashleigh","email":"ashleighsimonelli@gmail.com"}],"_npmUser":{"name":"bashleigh","email":"ashleighsimonelli@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nestjs-amqp_0.0.2_1531219030964_0.963658953887681"},"_hasShrinkwrap":false}},"maintainers":[{"name":"bashleigh","email":"ashleighsimonelli@gmail.com"}],"description":"RabbitMQ service for nestjs","keywords":["nestjs","amqp"],"repository":{"type":"git","url":"https://github.com/bashleigh/nestjs-amqp.git"},"license":"MIT","readme":"Nestjs AMQP\n===\n\nAn amqp connection service for nestjs.\n\n## Install\n\n## tests\n\n## TODO \n\n- [x] Manage multiple connections\n- [x] Add configuration data\n- [x] Add locallaised config via inject or however nestjs prefers \n- [ ] Close connection on termination\n- [ ] Retry connection on failure\n- [ ] Make documentation in readme easier to follow\n- [ ] Add examples\n\n```javascript\nimport {\n    Module,\n} from '@nestjs/common';\nimport ConfigModule from '@bashleigh/nest-config';\n\n@module({\n    imports: [ConfigModule, AmqpModule.forRoot([\n        {\n            host: 'amqp://test:test@localhost',\n        }, \n        {\n            username: 'test',\n            password: 'test',\n            host: 'localhost',\n            port: 5672,\n            ssl: true,\n            name: 'test',\n        }\n    ])],\n})\nexport default class TestModule {\n}\n```\n> Alternatively use the env method `AMQP_URL=amqp://test@test:localhost:5672`\n\n```javascript\nimport {\n    Injectable,\n} from '@nestjs/common';\nimport {\n    InjectAmqpConnection,\n} from '@bashleigh/nestjs-amqp';\n\n@Injectable()\nexport default TestService {\n    constructor(\n        @InjectAmqpConnection('test') private readonly connectionTest, //gets connection with name 'test' defined in module\n        @InjectAmqpConnection(1) private readonly connection1, //gets first defined connection without a name\n    ) {}\n}\n```\n> Use InjectAmqpConnection without a parameter for default connection\n\n## Future implementation\n\nSo far this package manages multiple AMQP connections using the nestjs container and inject them into other providers.  \nAlternatively I'd like to implement something like this:\n\n```javascript\nimport {\n    Injectable,\n} from '@nestjs/common';\nimport {\n    AmqpConnection,\n    Consume,\n    Publish,\n    Message,\n} from '@bashleigh/nestjs-amqp';\n\n@Injectable()\n@AmqpConnection()\nexport default class MyAmqpService {\n   \n    @Consume(\"queue_name\", {\n        noAck: true,\n    })\n    async listen(@Message message) {\n        console.log('Message received', message);\n        \n        //send a message back\n        this.publish();\n    }\n\n    @Publish(\"queue_name\")\n    async publish() {\n        return \"Send this to 'queue queue_name'\";\n    }\n}\n```\n\nThen using executable context \n\n```javascript \n\nimport { NestFactory } from '@nestjs/core';\nimport QueueModule, { MyAmqpService } from './queue';\n\nasync function bootstrap() {\n  const app = await NestFactory.create(QueueModule);\n  const event = app.get(MyAmqpService);\n\n  await event.listen();\n\n}\nbootstrap();\n\nprocess.stdin.resume();\n```\n\nOr something similar to the above is what I'd like to implement","readmeFilename":"README.md"}