{"_id":"@dav-m85/thrift-express-middleware","_rev":"1-db391539b1d949e3761cc4c5496af343","name":"@dav-m85/thrift-express-middleware","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@dav-m85/thrift-express-middleware","version":"1.0.0","description":"Express server middleware for proxying Apache Thrift server","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"engines":{"node":">=6"},"author":{"name":"David Moreau","email":"dav.m85@gmail.com"},"license":"MIT","dependencies":{"body-parser":"^1.18.3"},"gitHead":"844478e63b914d4b57c8a38133ba364c46961199","_id":"@dav-m85/thrift-express-middleware@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.11.1","_npmUser":{"name":"dav-m85","email":"dav.m85@gmail.com"},"dist":{"integrity":"sha512-VLS5g58wq6FrxXBGGkCZ6D8amEs4RBFWKH06w3HBNOGEungM7zXZ1IHyJVznya4PELYyIMxsR62WaQd3nwQqZQ==","shasum":"1ca5ad0a72a60b5aefc1f0f374288273912d9ad4","tarball":"https://registry.npmjs.org/@dav-m85/thrift-express-middleware/-/thrift-express-middleware-1.0.0.tgz","fileCount":3,"unpackedSize":5157,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbPo+KCRA9TVsSAnZWagAAY/IQAI2j8I3/dW/lzC0eyyv/\na8Y30BqdsnwjehHvVFKdAj2JeEUesfAgT6yGPQdju2Pt8Fz6XVGoHBVC5T0r\nTqvgn4z/dEGNVRTo49cGRRzphgzMLMNutnpbpWgPFSg4XMKj97IHul1JS4+S\nJ8jCJu6ZXnOiy5PKAwFcwmv55iVoRV5IFXdH2SiKUDygDOrMNy5ZmGcaabmP\n9/3ImXoSjJ9FQSw5Ri7xFK9Wke3y7kiHCXWuWgcGBqcq/CaTqX7e30KtsSY/\n0mFOG17H8t8HfZzvgO/OH2EEWaYZsgI7YS6eF45+kd/WJjhor4FYuGMJzFBW\nji/yM9UDowIsSrYncESdH4N6P7wQvED3urN0cszpvM2pcyEKTsFtBd8FEqL/\nwkwdDdHD6+8LBgXBQXcExvqjrt2aog6pw/FaEcidJq4++VeJ/0cFKiVuR5n1\nlwMcdQrTRN1oEHSR4o2nlheEzAd+q8ZIgtktediIjPgkz3Mx3G0DOyNC8oaW\ndo5DLrSdPb9m5pi5+AhkdAukwND832/aRZBLO/ESNFCthtPBdOLvWvUCa4SU\n64lLSax685EvfTZcIFhZEq6SIrPyi2mJmhEbDl09Sz5pE8KebG2L7G9cAbs2\nE7EWbJrnNXMGmB0cFdjIzaRysubZNvRV5zi7K/+ykTMskaw1YKysnuFJmZY6\nulbF\r\n=jHwy\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCXR8NtV43iW5IpdoskpsuzLNdWETEBRiucFsTsgWMnYAIgD1cg6t9FGjlatYli/DA6aSQjxYPwizVA5MBHkWm7oso="}]},"maintainers":[{"name":"dav-m85","email":"dav.m85@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/thrift-express-middleware_1.0.0_1530826634458_0.9467175359932647"},"_hasShrinkwrap":false}},"time":{"created":"2018-07-05T21:37:14.227Z","1.0.0":"2018-07-05T21:37:14.548Z","modified":"2022-04-05T03:04:48.467Z"},"maintainers":[{"name":"dav-m85","email":"dav.m85@gmail.com"}],"description":"Express server middleware for proxying Apache Thrift server","author":{"name":"David Moreau","email":"dav.m85@gmail.com"},"license":"MIT","readme":"# @dav-m85/express-thrift-middleware\n\n> Express server middleware for proxying Apache Thrift server\n\n[![NPM][npm-icon]][npm-url]\n\n[![standard][standard-image]][standard-url]\n\n## Install\n\nRequires [Node](https://nodejs.org/en/) version 6 or above.\n\n```sh\nnpm i @dav-m85/express-thrift-middleware\n```\n\n## Use\n\nYou need to use the excellent [Apache Thrift protocol](https://thrift.apache.org/lib/js) alongside your express server ? This middleware ease it for you.\n\n```js\n// Server code\nconst app = (require('express'))()\nconst thrift = require('thrift')\nconst ThriftMiddleware = require('./ThriftMiddleware')\n\n// I use the tutorial example here. Got this file by running\n// thrift -r --gen js:node tutorial.thrift\nlet Calculator = require('./gen-nodejs/Calculator')\nlet handler = {\n  ping: function (result) {\n    console.log('ping()')\n    result(null)\n  }\n}\n\napp.use(\n  // Puts the proxied thrift server in the path you want (here /rpc). Don't forget\n  // to configure your client accordingly (see below)\n  '/rpc',\n  // You can prepend here additional middlewares if needed, like cors or authentication\n  ThriftMiddleware({\n    handler,\n    // Please note, only TBufferedTransport and TJSONProtocol are supported right now\n    // PR accepted for extensing what can be proxied to thrift\n    transport: thrift.TBufferedTransport,\n    protocol: thrift.TJSONProtocol,\n    processor: Calculator\n  })\n)\n```\n\n```js\n// Example client code with webpack\n// Same as official tutorial, except we're using the nodejs generated binding,\n// and we point at the browser implementation for createXHRConnection\nconst thrift = require('thrift/lib/nodejs/lib/thrift/browser')\nconst Calculator = require('./gen-nodejs/Calculator')\nconst transport = thrift.TBufferedTransport\nconst protocol = thrift.TJSONProtocol\n\nconst connection = thrift.createXHRConnection('myhost', myport, {\n  transport: transport,\n  protocol: protocol,\n  // We declare the configured path on the server\n  path: '/rpc'\n})\n```\n\nEt voilà ! 👊\n\n### Credits\nThis code is inspired from [creditkarma](https://github.com/creditkarma/thrift-server/tree/master/packages/thrift-server-express)'s implementation in typescript.\n\nAuthor: David Moreau &lt;dav.m85@gmail.com&gt; &copy; 2018\n\nLicense: MIT - do anything with the code, but don't blame me if it does not work.\n\nSupport: if you find any problems with this module, email / tweet /\n[open issue](todo...) on Github\n\n## MIT License\n\nCopyright (c) 2018 David Moreau &lt;dav.m85@gmail.com&gt;\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\n[npm-icon]: https://nodei.co/npm/arguments-as-string.svg?downloads=true\n[npm-url]: https://npmjs.org/package/arguments-as-string\n[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg\n[standard-url]: http://standardjs.com/\n","readmeFilename":"README.md"}