{"_id":"@connectedyard/restify-await-promise","_rev":"11-9690f310fb60355083559df027736c68","name":"@connectedyard/restify-await-promise","dist-tags":{"latest":"2.3.1"},"versions":{"2.3.0":{"name":"@connectedyard/restify-await-promise","version":"2.3.0","description":"Restify Plugin to support promises and async/await","license":"MIT","repository":{"type":"git","url":"git+https://github.com/PhinCo/restify-await-promise.git"},"keywords":["restify","promise","async-await"],"author":{"name":"ConnectedYard, Inc."},"bugs":{"url":"https://github.com/PhinCo/restify-await-promise/issues"},"homepage":"https://github.com/PhinCo/restify-await-promise#readme","peerDependencies":{"restify":">=4.0.0"},"devDependencies":{"chai":"^4.2.0","eslint":"^5.16.0","mocha":"^6.2.0","request":"^2.88.0","request-promise":"^4.2.4","restify":"^7.7.0","sinon":"^7.4.1"},"scripts":{"test":"_mocha --recursive tests","lint":"node_modules/eslint/bin/eslint.js index.js \"tests/**/*.js\""},"gitHead":"ddc2038f29f32626202d0dfea12ecd4ed9150515","_id":"@connectedyard/restify-await-promise@2.3.0","_nodeVersion":"12.11.1","_npmVersion":"6.11.3","_npmUser":{"name":"jkennedy1980","email":"josh@phin.co"},"dist":{"integrity":"sha512-J6HsYbdluL608xWSy47fsd9bbQ/yEtpI3QqpTjP1oLmvTqRNnRWzmDWteibiTBe6F3JXIRkZFHSOkC8cFZ0tpw==","shasum":"97d05655c267ffa94b9d1de4672c73e4b50a08d9","tarball":"https://registry.npmjs.org/@connectedyard/restify-await-promise/-/restify-await-promise-2.3.0.tgz","fileCount":6,"unpackedSize":9565,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdpzenCRA9TVsSAnZWagAAkoYQAIONBu2WMdPnnmZEAi/s\nbrS/fK1myvmJlWUEtoE1Dfz07lV7TONCATlCeI9ATKyTrOuQ1iUtOXbQ+cO7\ndn+t2t4dMfOtANltbDolCdCcWsBQOjU3xxvxxUAW9JZZI6vj0MGGYBrPizov\nlZ5XjUKyodl0teC7+BXY/jrjHXGS6NgRMQsLPXh5F9MxAZzxvQEQovaE5JWm\n/QQmLVxdf+2eBsEK+5TneMRAzXocNGRyjMcqk6M+yhJj9pEecRvsc3HVhJD7\nLxz6zoXKSXnaMDLL/suGzkpJxRcjuGWP8WXBaSpCTVXeMR/FEjz05kpDDaPg\nhpIdFOOEmquYP3W7BxeR/oRUHzR69pfHGsBzMRYTbJ9s3Nf5PziTncJ8ryTA\neUiPpyz8+sgfKdrOcUIKohcsBX8226ECXAEFDnjDeHd/xyqsWp39vNjkXHGw\nBDPJ9qgaWnpzHXB7MRQrSa3vyQ05hIPE6Ydp/y5HHGnpBJf4FkiEZls7TKDC\nHVFzL1nC5xlUynY0neXoURWMeowDEpfjgRpPtYAmpAEM7GshfB7xwgKjgdMc\n84yOTEe3KJzsh8MCSlRYc1AaITEKz1P1WYGN6zaHsfZmp1bXUO8r8U+91tRi\nA7TxtDE4wDPGijoC+uwPRWZ7AdFhX/djFxo/xT2t4YggIyQYmz/A1dJUEZgA\nEV62\r\n=rWfq\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA2MPGfOfWgr4PTXUC3HSVzYj+oNqy0A77mU7OpjoTBOAiAGR4ePSmIXaby4z9fSIIPDrBAeKtWyjOKIxx85Gkf6tg=="}]},"maintainers":[{"name":"remotevision","email":"ryan@phin.co"},{"name":"zach.winter","email":"zach@phin.co"},{"name":"jolson474","email":"jolson474@gmail.com"},{"name":"patricklmead","email":"patricklmead@gmail.com"},{"name":"jkennedy1980","email":"josh@phin.co"},{"name":"corim707","email":"ross@phin.co"},{"name":"homedad","email":"scott@phin.co"},{"name":"baniares","email":"npmjs@baniares.com"},{"name":"geetaristo","email":"michael.luttrell@gmail.com"},{"name":"jeremyrambo","email":"jeremy@phin.co"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/restify-await-promise_2.3.0_1571239847087_0.10965785413396989"},"_hasShrinkwrap":false},"2.3.1":{"name":"@connectedyard/restify-await-promise","version":"2.3.1","description":"Restify Plugin to support promises and async/await","license":"MIT","repository":{"type":"git","url":"git+https://github.com/PhinCo/restify-await-promise.git"},"keywords":["restify","promise","async-await"],"author":{"name":"ConnectedYard, Inc."},"bugs":{"url":"https://github.com/PhinCo/restify-await-promise/issues"},"homepage":"https://github.com/PhinCo/restify-await-promise#readme","peerDependencies":{"restify":">=4.0.0"},"devDependencies":{"chai":"^4.2.0","eslint":"^5.16.0","mocha":"^6.2.0","request":"^2.88.0","request-promise":"^4.2.4","restify":"^7.7.0","sinon":"^7.4.1"},"scripts":{"test":"_mocha --recursive tests","lint":"node_modules/eslint/bin/eslint.js index.js \"tests/**/*.js\""},"gitHead":"bcfb27f8069c3493b0243dfc49848a54ae092452","_id":"@connectedyard/restify-await-promise@2.3.1","_nodeVersion":"12.11.1","_npmVersion":"6.11.3","_npmUser":{"name":"jkennedy1980","email":"josh@phin.co"},"dist":{"integrity":"sha512-Ru9IbA6xrdtZdy7id4Z69xBxoI2CAH6TLbkmpe0Rdaly7EWc9qKlRBbCnwu54EKMp1o0g+FalsbTpIQLo6S9gQ==","shasum":"baa4a50a9bb4994707065095eab6ff4cec3ea520","tarball":"https://registry.npmjs.org/@connectedyard/restify-await-promise/-/restify-await-promise-2.3.1.tgz","fileCount":6,"unpackedSize":9565,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdpz6lCRA9TVsSAnZWagAASzEP/i4GjxgP10XNz4DA7ltt\nSTssWqrrU/aor++KnRy444EpjGgT9FxkeIYJlK7mVsvLtk+il0srXKM/G7nk\nKDM/+KkRWLEW1Hsfs7lMA7TLsw66LkZaQfoYZ/3j4RAnru/kUOEG7DZ8f4hY\nOaP0DUIExvQg/ELSncKhYFStcqCPdrqv35rPl31598m0TZRYxVh8oBU4wTRM\n/4lMxeYKxILiWCU8tloGEM6D2XvXn5Yy6hov3avGYBpK0EVEaqN3Z3y63VBH\nT8wz7cI0ZrbUlLX+qiP1ceqKoXNhEg7C1vmuMpum73LcdxL+O+fvbepqGAsn\nnlea3vFQfyQHx9k0m60Ezo39T+INFn9aHFjqLRaLd3iDzgiOQ54V8R/m79ZV\nD4fpcm9B1vzwm3JU1OoWETSsxtsPsNWqr+9QHOLSQZTUbDtMK8v7+9r2AZ1J\nQAW4jiWNl7mcTWLoQNCeXiAfOkwbNeUjr151uwJsiVjM8cqLnqQP8xL9e3pD\nDEAsEjylfbIJ5BUBz9je/ywwnWRGC3wb2gPw/bBpfY+EeDXlirZI3OERvA58\nFaiMRVzel91Nf0pm8Po66iNMXVgpZlGURPU8BkTghZjEt3+HvnxtHK1n9JZ7\nQ8FhS/zk7hJCrs2oVWdYmQIe4mGr+03x9wSYbcg20s41ne+UUpUwDwQ+BRJo\nXzZ9\r\n=OI8+\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEFV8XP5Zao5hKy1c7tmYAhojmILVTupgb2WV7KywujWAiA8ArtvTvWmgAYf6RUgh3rOUcFlz+vuSqxgtDZL1zf2RA=="}]},"maintainers":[{"name":"baniares","email":"npmjs@baniares.com"},{"name":"corim707","email":"ross@phin.co"},{"name":"geetaristo","email":"michael.luttrell@gmail.com"},{"name":"homedad","email":"scott@phin.co"},{"name":"jeremyrambo","email":"jeremy@phin.co"},{"name":"jkennedy1980","email":"josh@phin.co"},{"name":"jolson474","email":"jolson474@gmail.com"},{"name":"patricklmead","email":"patricklmead@gmail.com"},{"name":"remotevision","email":"ryan@phin.co"},{"name":"zach.winter","email":"zach@phin.co"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/restify-await-promise_2.3.1_1571241636781_0.29025812839050613"},"_hasShrinkwrap":false}},"time":{"created":"2019-10-16T15:30:47.086Z","2.3.0":"2019-10-16T15:30:47.200Z","modified":"2022-04-05T00:55:35.181Z","2.3.1":"2019-10-16T16:00:37.260Z"},"maintainers":[{"email":"nboucher@pipartners.com","name":"nboucherpip"},{"email":"jolson474@gmail.com","name":"jolson474"},{"email":"patricklmead@gmail.com","name":"patricklmead"},{"email":"josh@phin.co","name":"jkennedy1980"},{"email":"scott@phin.co","name":"homedad"},{"email":"npmjs@baniares.com","name":"baniares"},{"email":"michael.luttrell@gmail.com","name":"geetaristo"}],"description":"Restify Plugin to support promises and async/await","homepage":"https://github.com/PhinCo/restify-await-promise#readme","keywords":["restify","promise","async-await"],"repository":{"type":"git","url":"git+https://github.com/PhinCo/restify-await-promise.git"},"author":{"name":"ConnectedYard, Inc."},"bugs":{"url":"https://github.com/PhinCo/restify-await-promise/issues"},"license":"MIT","readme":"# restify-await-promise\n\n[![Build Status](https://travis-ci.org/PhinCo/restify-await-promise.svg)](https://travis-ci.org/PhinCo/restify-await-promise)\n[![dependency Status](https://david-dm.org/PhinCo/restify-await-promise/status.svg)](https://david-dm.org/PhinCo/restify-await-promise#info=dependencies)\n[![peerDependency Status](https://david-dm.org/PhinCo/restify-await-promise/peer-status.svg)](https://david-dm.org/PhinCo/restify-await-promise#info=peerDependencies)\n[![devDependency Status](https://david-dm.org/PhinCo/restify-await-promise/dev-status.svg)](https://david-dm.org/PhinCo/restify-await-promise#info=devDependencies)\n\nConverts restify routes to support async/await and returned promises.  Works with Restify 4.x through 6.x.  May work with Restify 7+.  \n\n\n#Supported Restify Versions\n* Fully Supported\n  * 4.x to 5.x\n* Probably Works\n  * 6.x\n* Partially Compatible\n  * 7.x+ <br>\n\n# Usage\n\n```javascript\nconst restify = require('restify');\nconst restifyPromise = require('restify-await-promise');\n\nconst server = restify.createServer({\n  name: 'myapp',\n  version: '1.0.0'\n});\n\n//Allows you to manipulate the errors before restify does its work\nconst alwaysBlameTheUserErrorTransformer = {\n\ttransform: function( exceptionThrownByRoute ){\n\t\t//Always blame the user\n\t\texceptionThrownByRoute.statusCode = 400; \n\t\treturn exceptionThrownByRoute;\n\t}\n}\n\nconst options = {\n\tlogger: yourLogger,                                  //Optional: Will automatically log exceptions\t\n\terrorTransformer: alwaysBlameTheUserErrorTransformer //Optional: Lets you add status codes \n};\n\nrestifyPromise.install( server, options ); // Options is not required\n\n// Async function, automatically calls send with the returned object and next\nserver.get('/lookup/:name', async function (req) {\n\treturn await SomePromise.work( req.parms.name );\n});\n\n// Promise function\nserver.get('/echo/:name', function (req) {\n\tconst params = req.params; \n\treturn Promise.resolve( { params } );\n});\n\n// Existing restify method\nserver.get('/echo2/:name', function (req, res, next) {\n\t  res.send(req.params);\n\t  next();\n});\n\n// Versioned Route with Restify 7+\nserver.get('/seek/:enlightenment', restifyPromise.asyncConditionalHandler([\t\n\t{\n\t\tversion: \"1.0.0\",\n\t\thandler: async function (req) {\n\t\t\tconst result = await searchFor( req.parms.enlightenment );\n\t\t\treturn result;\n\t\t}\n\t}\n]));\n\nserver.listen(8080, function () {\n\t  console.log('%s listening at %s', server.name, server.url);\n});\n```\n\n\n# Installation\n```bash\n$ npm install --save restify-await-promise\n```\n\n## Bugs\n\nSee <https://github.com/PhinCo/restify-await-promise/issues>.\n","readmeFilename":"README.md"}