{"tsd":{"directory":"test"},"bugs":{"url":"https://github.com/fastify/fastify-http-proxy/issues"},"dist":{"shasum":"9585ae57fb8e529796750d1704184fa0bbb86d99","tarball":"https://registry.npmjs.org/fastify-http-proxy/-/fastify-http-proxy-4.0.0.tgz","fileCount":16,"integrity":"sha512-s5kfYPRQZ44+OLJdhxbR86kPA3j1k2keW3wxZJJfEUD/9/GqwXch5lUZT32oyou+K+N6xeie+R3RD/ZMzk8mfA==","signatures":[{"sig":"MEUCIQCfXzZVc64ubFsbOmkkbCjLl9qYAFAIdfUzzY60qyVqGwIgLpUdEoCXVOtr84GW8dFgr86Vsovi8VUVi5xf4kZmo/s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":24776,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe6MpUCRA9TVsSAnZWagAAjmsP/RdP5qzbcQRJsNNkPScu\ndi8AWbPHLA38qiEMZXguNmnfprMoZT87pOtsk9H0VJep390BC0WWmyDbItBJ\njkp3/YNS+wGcJkRmiGu0rJzprbfBIbbX/NLXQtZoONeiqCtpdrRZ04EVfpE/\n5EF25b6/jJ3/OGRN32GtK8FesBzrAGTnn5DDfyaWm3zfJwvGuiCfvDpMvbp2\n7pETuip9B65BUTxv3hurIbsBDbBqCStAxPOqWpA+wViMlcbra9S9YZqMh/nF\ntcxl+Ro+MYAk1PcwOCFydo/p2W/VMvdhgZS/LM7PHHQy67e6OsRoaTtB7pmu\nEkoXorVCmBjL/QaMxTQuEi/dddx9GJ8a9uXpP2Pye4B+yrNqAj61+TECtJvu\nqmvu0crgszHtlRq3iSudzLKxyyEMgdJhEouCM+pRZtWdgr7hq7IXOFTdIjE8\nFz44HoMmM7Yv6gR58uVh5dXXBO6IAhWzY/QyuDpb2A9kC8uHktu4XZhixFbh\nABoxkKD9CfwYvVaHVonqzqjRX01XNYPWn7WxXg4ki6ggVGkBxGztgTKzn5kU\n37714h+o54aocY0dSUa6jHMer+ec4/n00ub0OQVIDmrhm55XhMTfL6Z0t2lm\nbldrVF/Ua7b+D43XCTSwBVcCj3cIuPDuwQfwRO8RzZIJe02Eh+d1aswwdwon\n3Gee\r\n=ATYN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","name":"fastify-http-proxy","author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"readme":"# fastify-http-proxy\n\n[![Build Status](https://travis-ci.org/fastify/fastify-http-proxy.svg?branch=master)](https://travis-ci.org/fastify/fastify-http-proxy)\n\nProxy your http requests to another server, with hooks.\nThis [`fastify`](https://www.fastify.io) plugin forward all the request\nreceived with a given prefix (or none) to an upstream. All Fastify hooks are still applied.\n\n`fastify-http-proxy` is built on top of\n[`fastify-reply-from`](http://npm.im/fastify-reply-from), which enables\nyou for single route proxying.\n\nThis plugin can be used in a variety of circumstances, for example if you have to proxy an internal domain to an external domain (useful to avoid CORS problems) or to implement your own API gateway for a microservices architecture.\n\n## Requirements\n\nFastify 2.x. See [this branch](https://github.com/fastify/fastify-http-proxy/tree/1.x) and related versions for Fastify 1.x compatibility.\n\n## Install\n\n```\nnpm i fastify-http-proxy fastify\n```\n\n## Example\n\n```js\nconst Fastify = require('fastify')\nconst server = Fastify()\n\nserver.register(require('fastify-http-proxy'), {\n  upstream: 'http://my-api.example.com',\n  prefix: '/api', // optional\n  http2: false // optional\n})\n\nserver.listen(3000)\n```\n\nThis will proxy any request starting with `/api` to `http://my-api.example.com`. For instance `http://localhost:3000/api/users` will be proxied to `http://my-api.example.com/users`.\n\nIf you want to have different proxies on different prefixes in you can register multiple instances of the plugin as shown in the following snippet:\n\n```js\nconst Fastify = require('fastify')\nconst server = Fastify()\nconst proxy = require('fastify-http-proxy')\n\nserver.register(proxy, {\n  upstream: 'http://my-api.example.com',\n  prefix: '/api', // optional\n  http2: false // optional\n})\n\nserver.register(proxy, {\n  upstream: 'http://single-signon.example.com/auth',\n  prefix: '/auth', // optional\n  http2: false // optional\n})\n\nserver.listen(3000)\n```\n\nNotice that in this case it is important to use the `prefix` option to tell the proxy how to properly route the requests across different upstreams.\n\nFor other examples, see `example.js`.\n\n## Options\n\nThis `fastify` plugin supports _all_ the options of\n[`fastify-reply-from`](https://github.com/fastify/fastify-reply-from) plus the following.\n\n*Note that this plugin is fully encapsulated, and non-JSON payloads will\nbe streamed directly to the destination.*\n\n### upstream\n\nAn URL (including protocol) that represents the target server to use for proxying.\n\n### prefix\n\nThe prefix to mount this plugin on. All the requests to the current server starting with the given prefix will be proxied to the provided upstream.\n\nThe prefix will be removed from the URL when forwarding the HTTP\nrequest.\n\n### rewritePrefix\n\nRewrite the prefix to the specified string. Default: `''`.\n\n### preHandler\n\nA `preHandler` to be applied on all routes. Useful for performing actions before the proxy is executed (e.g. check for authentication).\n\n### proxyPayloads\n\nWhen this option is `false`, you will be able to access the body but it will also disable direct pass through of the payload. As a result, it is left up to the implementation to properly parse and proxy the payload correctly.\n\nFor example, if you are expecting a payload of type `application/xml`, then you would have to add a parser for it like so:\n\n```javascript\nfastify.addContentTypeParser('application/xml', (req, done) => {\n  const parsedBody = parsingCode(req)\n  done(null, parsedBody)\n})\n```\n\n### config\n\nAn object accessible within the `preHandler` via `reply.context.config`.\nSee [Config](https://www.fastify.io/docs/v2.1.x/Routes/#config) in the Fastify\ndocumentation for information on this option. Note: this is merged with other\nconfiguration passed to the route.\n\n### replyOptions\n\nObject with [reply options](https://github.com/fastify/fastify-reply-from#replyfromsource-opts) for `fastify-reply-from`.\n\n## websocket\n\nThis module has _partial_ support for forwarding websockets by passing a\n`websocket` option. All those options are going to be forwarded to\n[`fastify-websocket`](https://github.com/fastify/fastify-websocket).\nA few things are missing:\n\n1. forwarding headers as well as `rewriteHeaders`\n2. support for paths, `prefix` and `rewritePrefix`\n3. request id logging\n\nPull requests are welcome to finish this feature.\n\n\n## Benchmarks\n\nThe following benchmarks where generated on a Macbook 2018 with i5 and\n8GB of RAM:\n\n| __Framework__ | req/sec |\n| :----------------- | :------------------------- |\n| `express-http-proxy` | 878.4 |\n| `http-proxy` | 3837 |\n| `fastify-http-proxy` | 4205 |\n| `fastify-http-proxy` (with [`undici`](https://github.com/mcollina/undici)) | 6235.6 |\n\nThe results where gathered on the second run of `autocannon -c 100 -d 5\nURL`.\n\n## TODO\n\n* [ ] Generate unique request ids and implement request tracking\n* [ ] Perform validations for incoming data\n* [ ] Finish implementing websocket (follow TODO)\n\n## License\n\nMIT\n","gitHead":"fc8266652f44b8598b131c8d5fe50a9d214149d0","license":"MIT","scripts":{"test":"standard | snazzy && tap test/*.js","typescript":"tsd","lint:typescript":"standard --fix --parser @typescript-eslint/parser --plugin typescript test/types/*.ts"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"homepage":"https://github.com/fastify/fastify-http-proxy#readme","keywords":["fastify","http","proxy"],"repository":{"url":"git+https://github.com/fastify/fastify-http-proxy.git","type":"git"},"_npmVersion":"6.14.5","description":"proxy http requests, for Fastify","directories":{},"maintainers":[{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"cemremengu","email":"cemremengu@gmail.com"},{"name":"delvedor","email":"tommydelved@gmail.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"ethan_arrowood","email":"ethan.arrowood@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"starptech","email":"deusdustin@gmail.com"}],"_nodeVersion":"12.18.0","dependencies":{"ws":"^7.2.5","fastify-websocket":"^1.1.2","fastify-reply-from":"^3.1.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"got":"^11.3.0","tap":"^14.0.0","tsd":"^0.11.0","snazzy":"^8.0.0","express":"^4.16.4","fastify":"^3.0.0-alpha.1","standard":"^14.0.2","http-proxy":"^1.17.0","pre-commit":"^1.2.2","simple-get":"^4.0.0","typescript":"^3.4.5","@types/node":"^14.0.13","http-errors":"^1.7.1","express-http-proxy":"^1.5.0","make-promises-safe":"^5.0.0","eslint-plugin-typescript":"^0.14.0","@typescript-eslint/parser":"^3.3.0"},"_npmOperationalInternal":{"tmp":"tmp/fastify-http-proxy_4.0.0_1592314451586_0.3371043277982564","host":"s3://npm-registry-packages"},"_id":"fastify-http-proxy@4.0.0","version":"4.0.0"}