{"_id":"@api-typed/message-queue","_rev":"5-af3b2b5190dca7c509eacd60fad7ca1c","name":"@api-typed/message-queue","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.0-beta.0":{"name":"@api-typed/message-queue","version":"0.1.0-beta.0","description":"Message Queue tools based on BullMQ, prepared for Api-Typed","author":{"name":"Michal Palys-Dudek","email":"michal@pnd.io"},"license":"MIT","homepage":"https://github.com/api-typed/framework/tree/main/packages/message-queue#readme","bugs":{"url":"https://github.com/api-typed/framework/issues"},"repository":{"type":"git","url":"git+https://github.com/api-typed/framework.git"},"main":"dist/index.js","types":"dist/index.d.ts","directories":{"dist":"dist"},"scripts":{"build":"rimraf dist && tsc","dev":"tsc --watch","lint":"eslint ./src"},"dependencies":{"@api-typed/app":"^0.1.0-beta.0","@api-typed/common":"^0.1.0-alpha.18","@api-typed/config":"^0.1.0-alpha.18","@api-typed/logger":"^0.1.0-alpha.18","bullmq":"^1.21.0","lodash.omit":"^4.5.0","lodash.uniq":"^4.5.0"},"peerDependencies":{"typedi":"^0.8.0 || ^0.9.0 || ^0.10.0"},"devDependencies":{"@types/lodash.omit":"^4.5.6","@types/lodash.uniq":"^4.5.6"},"_id":"@api-typed/message-queue@0.1.0-beta.0","_nodeVersion":"14.13.0","_npmVersion":"7.6.3","dist":{"integrity":"sha512-mVVMuG+FSOu5fyoCyUzXWz/GxMTnOyvjJkNfDmE0uATtoJIP1/QrQDDvKcjDRDOoxhFi5wG4ltUW6Qrix8QyQg==","shasum":"2128585a682bcfdbcfdaf68639e779fc2342e35a","tarball":"https://registry.npmjs.org/@api-typed/message-queue/-/message-queue-0.1.0-beta.0.tgz","fileCount":32,"unpackedSize":29869,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgkc/bCRA9TVsSAnZWagAAB/sP/0QaueSeAFDkSzyTSnD5\nyH5nYmlAswd8ABx/KIRFEJ+1yucH4lgRfHopX2qLRUkP+n1nj7EzkexYcwRo\nHCHNBk7s2RBkNVE3yBl7CCkOUuJy2u3akTXZs6LiNfZWQahafcY/Z3foZb0Z\nSjQmMb4HptWZWxneft2dih0+k8xPFeLTy9DjBsXHftA++sjpxLuMmZEflFeS\nqO8e5WOjels3l5gtcnzrSaW1wiczJn6tqdfbvzc3+1Ey4BOeTdKs9a2fRQsN\nxn+BPWw/k2GDft+gAqeIm5oHMooQWArF4QdPY1cbG/lk7d+q2IOfOShgZdpu\nsKreqHlC/A/EtRZMIoei8LGVDnRmCnVE/YRumG4b1f+1SGrZL5otoiFY1bVb\nz6xWNOMwHJDaXyRndk/noBdcp+18R9niudpDpfbU2bcNPctukEPeBQQ5zKvY\n3WrOZqzcYiRBucT1We/rqU29LZRgvu/wNG0PMPo3dIcy630HWi1FlSDGD22z\nlUVmn996C7myMb0laRYZ9tY0v4oiavU3RcGBZoF89wuFGFvnMSvVn2U/HIfR\n8K0EBDS9Vj/+emJpQ3UJ9HaUvPTC0Rn7kMK04dIikmon4keV/4cYNMR1g1Y/\n/pk6Ep1ixYjD7Vp7g34SX8iZhel7hQ10KUGkAZUBukreEkTofPks1PBF9vms\n7K7R\r\n=zPze\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH4sPEq/ZRdgj1cyqIyDj/+8QnLiF/4o/83PUfYTTDy3AiAzvU3QnqCv4FoNRmuM5OVFySpISn8I00Y3Z2fL1ZFjqw=="}]},"_npmUser":{"name":"michaldudek","email":"michal@palys-dudek.pl"},"maintainers":[{"name":"michaldudek","email":"michal@palys-dudek.pl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/message-queue_0.1.0-beta.0_1620168666964_0.8783521628413717"},"_hasShrinkwrap":false},"0.1.0":{"name":"@api-typed/message-queue","version":"0.1.0","description":"Message Queue tools based on BullMQ, prepared for Api-Typed","author":{"name":"Michal Palys-Dudek","email":"michal@pnd.io"},"license":"MIT","homepage":"https://github.com/api-typed/framework/tree/main/packages/message-queue#readme","bugs":{"url":"https://github.com/api-typed/framework/issues"},"repository":{"type":"git","url":"git+https://github.com/api-typed/framework.git"},"main":"dist/index.js","types":"dist/index.d.ts","directories":{"dist":"dist"},"scripts":{"build":"rimraf dist && tsc","dev":"tsc --watch","lint":"eslint ./src"},"dependencies":{"@api-typed/app":"^0.1.0","@api-typed/common":"^0.1.0","@api-typed/config":"^0.1.0-alpha.18","@api-typed/logger":"^0.1.0","bullmq":"^1.21.0","lodash.omit":"^4.5.0","lodash.uniq":"^4.5.0"},"peerDependencies":{"typedi":"^0.8.0 || ^0.9.0 || ^0.10.0"},"devDependencies":{"@types/lodash.omit":"^4.5.6","@types/lodash.uniq":"^4.5.6"},"gitHead":"bd71c40d84d9ad6351fbd462af2408d4bd14a55d","_id":"@api-typed/message-queue@0.1.0","_nodeVersion":"14.13.0","_npmVersion":"lerna/4.0.0/node@v14.13.0+x64 (darwin)","dist":{"integrity":"sha512-1ha1NtAxwm1c1zOsQN0Fe/WT92bc9hZyJhJ/S3lgjlmm2vjtF5ROHlX9/TFj1uRVx/4NF6sCqXfVXHHhVYLl+g==","shasum":"e2f7873b98c31e4032f2849286a63f0d47dee774","tarball":"https://registry.npmjs.org/@api-typed/message-queue/-/message-queue-0.1.0.tgz","fileCount":33,"unpackedSize":32665,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgkyHXCRA9TVsSAnZWagAA09kP/1g5pN3D2Qrkjzt/Er0j\nfRQM6lP2Lb66VJxoOiaa3S8cGUs8wogLuIDk+GajnZGzld+iIw3zkCyHYKtO\nvS5K8BMVvJXNTN5Udq9W00RxnA8RKnp2ZlejuRBSv/zYU+sfl/2MOGPlEyA4\nEgyS3C0dsSqd5jjjEu2fv+E6J3oRC76i4HEdBmYp+7a160FxTnq8x9jDLd4z\nci8gi6sYfkAb6j4auPQacOULGsj3Ww/w7cTy4ARvB7UiNovVf+29DONUCDfi\nnaPFlgWttx8KnhkcHRQDFKtfQXvpMgR+TukvFagGHRnYl0IGePclAKYFmL0E\ndYhRmNn3h5Zk51J/40xLgPEfOgGnXCfL+2nMdY4/5xWP2K7iLYUwPcn02l7e\n5aUUFbRS7N1+9OClNo83iHacAYdSOxFtVVQg8oer5xWSOsktHS3lUfNUZ/fL\nHe37HYIM5hB9QK+tc8kEwjYNoF7+HV2y0Jtv5Jx6Sccqx4kNY+iOevwCXmgQ\nwKlKV4oN26gqpneipIeHjsy7vW3MTMBN5Fcg4Mh0E0lNEXsY9WYM2gvHSgDQ\nqWd5oAxeAJ1hYoWr8EppucQrXCOAHX1fSrPnBU2xAHTXhVs6nG5oZvDHRkLv\nWRGzmu4XVkr4EUiqB78BENfBxV+7YXVbAhBcKzPDK4qDJpeOSht1FeSedjm7\noFcD\r\n=sYTm\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDzZ/lOUAmZ/SZLvLhsmE8cNA59CBJZRU8Sdg/ifz49twIgdeLSyyBbbE7THjv96LVexjKhst8QZhAXG1jHGqeH0v4="}]},"_npmUser":{"name":"michaldudek","email":"michal@palys-dudek.pl"},"maintainers":[{"name":"michaldudek","email":"michal@palys-dudek.pl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/message-queue_0.1.0_1620255191157_0.4783271680644918"},"_hasShrinkwrap":false},"0.1.1":{"name":"@api-typed/message-queue","version":"0.1.1","description":"Message Queue tools based on BullMQ, prepared for Api-Typed","author":{"name":"Michal Palys-Dudek","email":"michal@pnd.io"},"license":"MIT","homepage":"https://github.com/api-typed/framework/tree/main/packages/message-queue#readme","bugs":{"url":"https://github.com/api-typed/framework/issues"},"repository":{"type":"git","url":"git+https://github.com/api-typed/framework.git"},"main":"dist/index.js","types":"dist/index.d.ts","directories":{"dist":"dist"},"scripts":{"build":"rimraf dist && tsc","dev":"tsc --watch","lint":"eslint ./src"},"dependencies":{"@api-typed/app":"^0.1.1","@api-typed/common":"^0.1.0","@api-typed/config":"^0.1.1","@api-typed/logger":"^0.1.0","bullmq":"^1.21.0","lodash.omit":"^4.5.0","lodash.uniq":"^4.5.0"},"peerDependencies":{"typedi":"^0.8.0 || ^0.9.0 || ^0.10.0"},"devDependencies":{"@types/lodash.omit":"^4.5.6","@types/lodash.uniq":"^4.5.6"},"gitHead":"3dba3c4abc20bbc7e2b341d4c582f955cff0b7b8","_id":"@api-typed/message-queue@0.1.1","_nodeVersion":"14.13.0","_npmVersion":"lerna/4.0.0/node@v14.13.0+x64 (darwin)","dist":{"integrity":"sha512-2GUNp5+e3ycajBmEOMcYV8GwycXyTXdxcUotSEQ070P3ICUvf4Y+qNP08bCfVTmewWskBV6uxpKjn3nIvrIrTg==","shasum":"52f747670fa8791416d7277e7286999f8e6a3ffd","tarball":"https://registry.npmjs.org/@api-typed/message-queue/-/message-queue-0.1.1.tgz","fileCount":33,"unpackedSize":43057,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgqYTmCRA9TVsSAnZWagAAh1QQAJm4J35B/+jOI24CFgJm\n22/rPwx3eh8UjEa8Axj+lyBJu+VdTlO846WmH9mvnSJDo1U/5F6WK5NgV9U7\nsfJ8t/ZDJEvTIEi4bsenwNuQjbzSKBRVCWHs3n5a6lrhfUPz/Le+mdnmBQ2j\nDlXNMozkJa1/fF6vaMg+MQPpV1rdl9CgnJsXno1isCSBol5RbwnTkFJ1dpat\nSb3UsK7dTPwcj4lKTWV+LTemCy2xfMCIR43JcSupXkuxV9Q2y3xVpXl5tnsm\nZbBWjuHv8aNRkfVEi/5egRp2z8xcVB2dHLj5Q9U0dmP78C4e/SSmhbjJg9iG\nGIhRat+nsyfaaTvj//OKfAsiycGW7ia555fMSsILGYrIUPgY88tma0YnBQ6M\nuHbI0dbGfCgxYvPXiN5Lkm+WYET6n7Ot4YSfaau5ogpF5bwxSTfpus+rFC6/\nwQeeAf17YiZj7DxkGgBWYjoGq9GWaGgIj6hlaZwEsNTrIeSB6XaTT0qphbyG\nbwoo7XZdk2lvGdJoL48IMsQN22RFzshUiExCxdvlC/S3FiRwu7q5EJCliB4r\nJdGZR9Hip6DEz0pJjsEWt4DN7laS/ATBy8eGtKzxwzkuWSKdvKqSFFdQv5ti\nL5nQl7VlCIyBlWf5kl0UgZUL1NNVdRB4B35hcBDWAWc9XZImlcPQzDgTkb0+\nITwB\r\n=eN3f\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB5cMZpYRfAK/1AySiqjIzJz525pyMrpiYNCPyAOq3MYAiEAohPaN7URDvvf7Wf8YIc7A8QJZBaAi1wmuljdlLYYODI="}]},"_npmUser":{"name":"michaldudek","email":"michal@palys-dudek.pl"},"maintainers":[{"name":"michaldudek","email":"michal@palys-dudek.pl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/message-queue_0.1.1_1621722342124_0.3155465868020355"},"_hasShrinkwrap":false},"0.1.2":{"name":"@api-typed/message-queue","version":"0.1.2","description":"Message Queue tools based on BullMQ, prepared for Api-Typed","author":{"name":"Michal Palys-Dudek","email":"michal@pnd.io"},"license":"MIT","homepage":"https://github.com/api-typed/framework/tree/main/packages/message-queue#readme","bugs":{"url":"https://github.com/api-typed/framework/issues"},"repository":{"type":"git","url":"git+https://github.com/api-typed/framework.git"},"main":"dist/index.js","types":"dist/index.d.ts","directories":{"dist":"dist"},"scripts":{"build":"rimraf dist && tsc","dev":"tsc --watch","lint":"eslint ./src"},"dependencies":{"@api-typed/app":"^0.1.1","@api-typed/common":"^0.1.0","@api-typed/config":"^0.1.1","@api-typed/logger":"^0.1.0","bullmq":"^1.21.0","lodash.omit":"^4.5.0","lodash.uniq":"^4.5.0"},"peerDependencies":{"typedi":"^0.8.0 || ^0.9.0 || ^0.10.0"},"devDependencies":{"@types/lodash.omit":"^4.5.6","@types/lodash.uniq":"^4.5.6"},"gitHead":"1d1095f8125bbe5bfebfe9180ece40a9422f7894","_id":"@api-typed/message-queue@0.1.2","_nodeVersion":"14.13.0","_npmVersion":"lerna/4.0.0/node@v14.13.0+x64 (darwin)","dist":{"integrity":"sha512-NCHdH2OYBzqxlX0FJ6q1Ek4W8RbQN93auUKYKoO7+ghqUANo/v5hciQC6pLR9n2oyYC+Qu2P3tqLbKo1WxIjDA==","shasum":"f04113c8461d64169a9fcd3c53a3c1bbf8dcb322","tarball":"https://registry.npmjs.org/@api-typed/message-queue/-/message-queue-0.1.2.tgz","fileCount":33,"unpackedSize":44106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg9IajCRA9TVsSAnZWagAA3PwQAJIwilaI712X8Tc40hLg\nKEisz9mijqP9cdI5mBPbOyglR5nilBKhW3Y3tiMwkgWtoZ3isBQHg1AvU+wh\neuC48JjyhHESv8NdiX6NPl7AJ7D/44XbrI4jlMuq7QM6mHk8bTeFaHFq/YUR\nJVFu7qdKbbqpPcdAIAVtgcLIiTpMYavKeTt0tTQydE5yg8/CSKdvyVsVYJLb\nRpIHzCFpv6FzCfmtSypd1qWC0ZOSy6qeIGfTEZ9ok5En+x+c34Y3RSHXbRw4\nD9Qiaq5B7mxBGsp//w0y3tNxWhk7cypqj+4+y/kTe8pu762iNyRcfowCDMhc\nMoonBl8WczLay0+QqLzRidx7EScxXyf1qx88FQdQbDTPUePFEwUoDMMSFwmZ\n7R7w05XqkdtUMpYCo0lKcKL3AcBsOdi5/MAao46b67I8JVKGIrpvpxvkrTpD\nLR0STiRdlo7z7F3OhtBwLHrlmg2V6Z1AzpWiszqRChjBEWJmGpaYAcBZxi3Y\nmOlHdHyIAbSPYm72yM/Cn7Dw8d8D28tKyWe03YA0rUxsFhSHyYyProRB/Rz9\nkiWmPXaPPKSh1FduQtm0ZOB8TzGnHYV9yErcRG3F+8vsY5gqjh19grI9fx+U\nVMB9LOoVpUsYvuPJhJUvlFbpcxfk3c+qOfjWbEwU0/DxUXr3MkhET44vuF9i\nL8sK\r\n=0+aX\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFLL/GZ+r2nFUiGzwKGmwzPJ2dmT7ondjSCNM9e4twNEAiBPvUELN+VEa2gjufFnyg6XaRGeseRrQoKxASkRnSzVZA=="}]},"_npmUser":{"name":"michaldudek","email":"michal@palys-dudek.pl"},"maintainers":[{"name":"michaldudek","email":"michal@palys-dudek.pl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/message-queue_0.1.2_1626637987627_0.15115673094415283"},"_hasShrinkwrap":false},"0.1.3":{"name":"@api-typed/message-queue","version":"0.1.3","description":"Message Queue tools based on BullMQ, prepared for Api-Typed","author":{"name":"Michal Palys-Dudek","email":"michal@pnd.io"},"license":"MIT","homepage":"https://github.com/api-typed/framework/tree/main/packages/message-queue#readme","bugs":{"url":"https://github.com/api-typed/framework/issues"},"repository":{"type":"git","url":"git+https://github.com/api-typed/framework.git"},"main":"dist/index.js","types":"dist/index.d.ts","directories":{"dist":"dist"},"scripts":{"build":"rimraf dist && tsc","dev":"tsc --watch","lint":"eslint ./src"},"dependencies":{"@api-typed/app":"^0.1.3","@api-typed/common":"^0.1.3","@api-typed/config":"^0.1.1","@api-typed/logger":"^0.1.0","bullmq":"^1.21.0","lodash.omit":"^4.5.0","lodash.uniq":"^4.5.0"},"peerDependencies":{"typedi":"^0.8.0 || ^0.9.0 || ^0.10.0"},"devDependencies":{"@types/lodash.omit":"^4.5.6","@types/lodash.uniq":"^4.5.6"},"gitHead":"097e4c93731a1996fa672619816758634aa5dec2","_id":"@api-typed/message-queue@0.1.3","_nodeVersion":"14.13.0","_npmVersion":"lerna/4.0.0/node@v14.13.0+x64 (darwin)","dist":{"integrity":"sha512-s37dppOCYYXRXMMdOOTriSPZgHvtZSajcPEmMaAxwd52KCUkIOFMxgYG4LLGMXkDNNvw7OsbEgCxI50Gf+K54Q==","shasum":"ead3cc5d0303306b7febdf1d22b3b0187ef524c1","tarball":"https://registry.npmjs.org/@api-typed/message-queue/-/message-queue-0.1.3.tgz","fileCount":33,"unpackedSize":44106,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg/I1dCRA9TVsSAnZWagAAOSgP/idVujG1bSxxcyrkpJp3\ngQsv6pJ0/Wnj4uGqz0vSgPjt1O5qqSVZ2JYrVqsX24lGrPT01wlyLhlXDmXo\nIqTsfsq5CS1+tDLzP1WwcS1oiymGFDNoUCQnk0BE66jhZinGZDh5pUGE1i1w\nICKKRIgMdroX0o5DkEcRLqojEu9DCMjVon5q9iOoJ+/i4HvZ873TLhazdQxo\nYMiBdLAm1eKsDlBlllY+D4GRZ2mjLQbrUSwsHbfovLKpv3uYhYJeTFdF1qqU\n69kBwdJiCUsIdKQ6CHNSw6O9pWNtSAhFPO3Cc5UJeCfNZ2LQxkVmrKQooL9P\n8jZmtSpsUSZQripqdt4AuMk1392ErnBq805s4LcXkinWux8Z4blltACm6WNP\nc3ibK1GLSki7WkDKIWXstld82Zo0NiRNGEaC0ztpJ2RUU2Szn3Q1hwLAgldI\nWD8mrqJGn1ODQX7O+zELOnybqFM3mg4BHabBUX0Mg+KTr2L6hokr/q6aEkxh\nzBuIN2pqA8ucIgIvUm6u3sz0x8L4DGPq92mhE2MW8ispghAcCwaJ8ptdzH32\nnb9lvwDSjKH4xbanpd3dTbjR64+0ZkNsXiBQXsKs4q5bECb2TRwI3U2ZXopJ\nnslsCo33Gdbd0vUYhQTxnIGPQTPZ23NQlhATQd/uLdvlOyzNXmIoLZFfpR7h\nLLUE\r\n=OtDM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFllZtZPuZty/LTdyUGL6NTu+9zgyvyF7g3SCITfQ10uAiBTOck0OmPxZ4/KAv7sS/NDuIebrE6vuLyp1hXqazcOYw=="}]},"_npmUser":{"name":"michaldudek","email":"michal@palys-dudek.pl"},"maintainers":[{"name":"michaldudek","email":"michal@palys-dudek.pl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/message-queue_0.1.3_1627163996970_0.9308775693301703"},"_hasShrinkwrap":false}},"time":{"created":"2021-05-04T22:51:06.626Z","0.1.0-beta.0":"2021-05-04T22:51:07.077Z","modified":"2022-04-04T14:34:23.245Z","0.1.0":"2021-05-05T22:53:11.323Z","0.1.1":"2021-05-22T22:25:42.255Z","0.1.2":"2021-07-18T19:53:07.759Z","0.1.3":"2021-07-24T21:59:57.108Z"},"maintainers":[{"name":"michaldudek","email":"michal@palys-dudek.pl"}],"description":"Message Queue tools based on BullMQ, prepared for Api-Typed","homepage":"https://github.com/api-typed/framework/tree/main/packages/message-queue#readme","repository":{"type":"git","url":"git+https://github.com/api-typed/framework.git"},"author":{"name":"Michal Palys-Dudek","email":"michal@pnd.io"},"bugs":{"url":"https://github.com/api-typed/framework/issues"},"license":"MIT","readme":"# 📯 Api-Typed/Message-Queue\n\n> 🥣 An [Api-Typed](https://github.com/api-typed/framework) component.\n\nWrapper around [BullMQ](https://docs.bullmq.io/) that abstracts away queue implementation and allows to register job handlers with a simple `@Job()` decorator.\n\n- Single `MessageQueue` class for adding jobs to queues.\n- One class per job helps to keep single responsibility principle.\n- Job configuration (target queue, retry strategy, generating id, etc.) lives in a single place.\n- Typed job payload that maps to the job handler's arguments 1:1.\n\n# At a glance\n\nDefine a job and its handler:\n\n```ts\n@Job<GreetingJob>({\n  queue: 'high_priority',\n  generateId: (greetId, name) => `job_${greetId}_${name}`,\n})\nexport class GreetingJob implements JobInterface {\n  public async run(\n    greetId: number,\n    name: string,\n    question?: string,\n  ): Promise<void> {\n    // implementation\n  }\n}\n```\n\nAdd a job to its queue:\n\n```ts\nconst messageQueue = new MessageQueue();\n\nmessageQueue.dispatch(GreetingJob, 234, 'Michael', 'How are you?');\n```\n\n1. Create a class that implements `JobInterface`.\n2. Define job payload as the `.run()` method arguments.\n3. Decorate it with `@Job()`:\n   a. Bind it to a queue.\n   b. Optionally provide a function to generate job ID based on payload.\n4. Somewhere in your application bootstrap configure `MessageQueue` object.\n5. Easily dispatch jobs with typed arguments (payload) as if they were regular function calls.\n6. Run worker with `$ npx api-typed run worker --with-scheduler` if using `Api-Typed` framework.\n\nYou can also use a dependency injection container!\n\n# Concepts\n\nWhile `@Api-Typed/Message-Queue` uses [BullMQ](https://docs.bullmq.io/) internally, it introduces several new concepts and changes how you interact with queues.\n\n## Single place for job configuration\n\nThe main concept of `@Api-Typed/Message-Queue` is that when you add a job to a message queue, it shouldn't be your concern at this time on which queue the job should end up or with what configuration the job should be added (unless you want to).\n\nLet's say you have a job to send log messages to Slack. This job is added to queues in many places in your code. All these places should not be concerned with how exactly this job is handled, on what queue it should be added or how many times it should be repeated until successful.\n\nWhat if you want to change that strategy? Should you update all the places where the job is being added? What if another developer adds this job to a different queue and blocks it?\n\n(Sure, sometimes it depends on the context, but 90% of the time this configuration should be the same regardless of where the job is triggered from.)\n\n## Single service class that routes jobs to their queues\n\nJust like the \"dispatchers\" of jobs should not be concerned with their configuration, they especially should not care to what queue a specific job belongs. They just want to add a job to processing and move on with their lives, most of the time not caring what happens to it.\n\nIn BullMQ you have to obtain `Queue` instance for appropriate queue and then add your job to it. With `@Api-Typed/Message-Queue` there is a single entry point, `MessageQueue` class, that takes care of adding jobs to their designated queues without having to take care of it yourself.\n\n# Setup\n\n## With Api-Typed\n\nTo get the best developer experience use it with [Api-Typed](https://github.com/api-typed/framework) in your `app.api-typed.ts` file:\n\n```ts\nimport { App, MessageQueueModule } from 'api-typed';\n\nexport default new App(__dirname, [\n  // ... your other modules\n  new MessageQueueModule(),\n]);\n```\n\nIt's already included for you out of the box when using [StandardApp](https://github.com/api-typed/framework/tree/main/packages/standard-app#readme).\n\nThen let your app module (or any module you create) implement `HasJobs` interface with a `loadJobs()` method that should return an array of class names that implement `JobInterface`.\n\nThe easiest way to do this:\n\n```ts\nimport { AbstractModule, HasJobs, loadJobs } from 'api-typed';\n\nexport class MyModule extends AbstractModule implements HasJobs {\n  public readonly name = 'my_module';\n\n  public loadJobs() {\n    // load all jobs from './jobs' dir relative to this file\n    return loadJobs(`${__dirname}/jobs/**/*.{ts,js}`);\n  }\n}\n```\n\nThen run worker that will handle all jobs with:\n\n```\n$ npx api-typed run worker --with-scheduler\n```\n\nYou can also run workers for specific queues:\n\n```\n$ npx api-typed run worker high_priority mid_priority --with-scheduler\n```\n\nOr you can run schedulers in separate processes (advised for better performance):\n\n```\n$ npx api-typed run worker\n$ npx api-typed run scheduler\n```\n\nYou need to run schedulers if you want to support delayed, scheduled or repeatable jobs.\n\n## Stand-alone\n\nYou can easily use this as a stand-alone package in any project.\n\n```\n$ npm i -S @api-typed/message-queue\n```\n\nYou need an entry point to run a worker:\n\n```ts\n// worker.ts\nimport { WorkerRunner, loadJobs } from '@api-typed/message-queue';\n\n// register all your jobs using a glob pattern so that the runner knows about\n// job handlers and all queues you're using\nloadJobs(`${__dirname}/jobs/**/*.{ts,js}`);\n\nconst runner = new WorkerRunner();\n\nrunner.start();\n```\n\nIf you want to run a scheduler the implementation is similar.\n\nTo start a worker just call the above script from your command line.\n\nNOTE: You probably also want to bootstrap your application so that the job handlers have access to your whole infrastructure. Therefore, the actual integration might be a bit more complex or part of a bigger system.\n\n# Registering jobs with `@Job()` decorator\n\nThe easiest way to create and register jobs handlers is by using the `@Job()` decorator on a class that implements `JobInterface`:\n\n```ts\nimport { Job, JobInterface } from '@api-typed/message-queue';\n\n@Job({\n  queue: 'high_priority',\n})\nexport class SomeJob implements JobInterface {\n  public async run(itemId: string, theAnswerToUniverse: number): Promise<void> {\n    // job implementation\n  }\n}\n```\n\nThe above code will configure the `SomeJob` to be always added to the `high_priority` queue and be handled by this class.\n\nThe name of the job that will actually be sent to BullMQ will be generated based on the class name. You can also specify it yourself by using `name: string` option or using the decorator like this:\n\n```ts\n@Job('custom_job_name', 'queue_name', {\n  // other options\n})\n```\n\n# Adding jobs\n\nBecause the queue to which a job should be added is configured right in the place where the job handler is defined, it is so much easier to add jobs to queues: a single `MessageQueue` class instance will route new jobs to their destination queues.\n\nAll the methods described below return a Promise that resolves with BullMQ's `Job` instance that describes the added job.\n\n## Dispatch job immediatelly\n\nIf you want a job to be dispatched immediatelly, meaning that it should be processed as soon as possible (which is most usually the case), you should use the `.dispatch()` method.\n\n```ts\nimport { MessageQueue } from '@api-typed/message-queue';\nimport { SomeJob } from './jobs/SomeJob';\n\n// this should happen somewhere in your app bootstrap\nconst mq = new MessageQueue();\n\nmq.dispatch(SomeJob, 'item-id', 42);\n```\n\nYes, the jobs are referred to by their class names. This guards you from ever making typos in strings or makes it unnecessary to come up with enums or consts with all the job names in the app.\n\nBut referring to jobs by their class names enabled one more powerful feature of `@Api-Typed/Message-Queue`:\n\n## Job payload and the `.run()` method\n\nNotice that in the examples above the `SomeJob.run()` method accepts two arguments: a string and a number and the call `.dispatch()` call also accepts a string and a number in its arguments.\n\nThis is because dispatching a job is almost like calling a function. You can type the job payload arguments just like you can type the job handler's `.run()` arguments.\n\nSo if your job handler expected arguments like this:\n\n```ts\nclass OtherJob implements JobInterface {\n  public async run(\n    otherId: string,\n    someValue: number,\n    items: string[],\n    options: {\n      doSomething?: boolean;\n    } = {},\n  ) {\n    // implementation\n  }\n}\n```\n\nYou would dispatch it like this:\n\n```ts\nmq.dispatch(OtherJob, 'other-id', 33, ['item1', 'item2', 'item3'], {\n  doSomething: true,\n});\n```\n\nAnd all these arguments would be properly typed!\n\nWith `@Api-Typed/Message-Queue` you don't have to wonder what payload a job accepts and be sure to always send the correct one.\n\nNOTE: Make sure the arguments you use on `.run()` method are as simple as possible, ie. they can be serialized into JSON.\n\n## Delay a job\n\nTo dispatch a job with a delay, to be processed after some time, use the `.schedule()` method:\n\n```ts\nmq.schedule(5000, SomeJob, 'item-id');\n```\n\nThe code above will add `SomeJob` to the queue to be processed after 5s (5000 ms).\n\nNOTE: You have to have a scheduler running for `SomeJob`'s designated queue in order for scheduling to work.\n\n## Schedule a job\n\nTo dispatch a job to be processed at a specific point in time, also use the `.schedule()` method, but with a `Date` object as the first argument:\n\n```ts\nmq.schedule(new Date('2022-05-01T00:20:00'), SomeJob, 'item-id');\n```\n\nThis will schedule the job to be processed on 1st of May, 2022 at 00:20.\n\nNOTE: If the date is in the past then the job will be processed immediatelly.\n\nNOTE: You have to have a scheduler running for `SomeJob`'s designated queue in order for scheduling to work.\n\n## Repeat a job on a schedule\n\nIf you want to repeat a job on a schedule, use the `.repeat()` method:\n\n```ts\nmq.repeat({ every: 3600 * 1000 }, SomeJob, 'item-id');\n```\n\nThis will make the job to be repeated every hour with the given payload.\n\nNOTE: You have to have a scheduler running for `SomeJob`'s designated queue in order for repeating to work.\n\n## Generic adding of jobs\n\nAnd if you ever need to overwrite the default configuration of a job and gain access to BullMQ's job options, use the `.addJob()` method:\n\n```ts\nmq.addJob(SomeJob, ['item-id'], {\n  /* job options */\n});\n```\n\nThe difference here is that instead of passing payload normally as subsequent arguments, you must pass them as an array in the second argument. The third argument are BullMQ's job options that will take precedence over any other configuration (except for designated queue).\n\n# Using Dependency Injection\n\nIf you want your job classes to be bootstrapped using a dependency injection container (like e.g. [TypeDI](https://github.com/typestack/typedi)) configure it by calling:\n\n```ts\nconst runner = new WorkerRunner();\nrunner.useContainer(/* your container */);\n```\n\nThe passed container MUST implement `.get(identifier: Function)` method that can construct and retrieve objects based on their class.\n\nThen your job class supports any methods of dependency injection that your container offers.\n\n# Generating job id's\n\nTo generate a job ID (e.g. so you can store a reference to it and then check its status) you can use the `generateId` option that accepts a function:\n\n```ts\n@Job<SomeJob>({\n  generateId: (someId, someNumber) => `some_job_${someId}_${someNumber}`,\n})\nexport class SomeJob implements JobInterface {\n  public async run(someId: string, someNumber: number) {\n    // implementation\n  }\n}\n```\n\nThe `generateId` function accepts the same arguments as the `.run()` method making it easy to generate the id based on job's payload. By adding type argument to the `@Job()` decorator we can reuse the types.\n","readmeFilename":"README.md"}