diff --git a/node_modules/express-http-proxy/package.json b/node_modules/express-http-proxy/package.json index 04cddf6eb..f91175880 100644 --- a/node_modules/express-http-proxy/package.json +++ b/node_modules/express-http-proxy/package.json @@ -6,14 +6,14 @@ "_location": "/express-http-proxy", "_phantomChildren": {}, "_requested": { - "type": "tag", - "registry": true, - "raw": "express-http-proxy", - "name": "express-http-proxy", "escapedName": "express-http-proxy", + "fetchSpec": "latest", + "name": "express-http-proxy", + "raw": "express-http-proxy", "rawSpec": "", + "registry": true, "saveSpec": null, - "fetchSpec": "latest" + "type": "tag" }, "_requiredBy": [ "#USER", @@ -21,11 +21,12 @@ ], "_resolved": "https://registry.npmjs.org/express-http-proxy/-/express-http-proxy-1.6.0.tgz", "_shasum": "8672b1093cc96b8a93e8e3da948dd111a668ef22", + "_shrinkwrap": null, "_spec": "express-http-proxy", "_where": "C:\\Users\\Administrator\\Documents\\project\\hc\\MicrCommunityWeb", "author": { - "name": "villadora", - "email": "jky239@gmail.com" + "email": "jky239@gmail.com", + "name": "villadora" }, "bugs": { "url": "https://github.com/villadora/express-http-proxy/issues" @@ -83,6 +84,9 @@ "license": "MIT", "main": "index.js", "name": "express-http-proxy", + "optionalDependencies": {}, + "readme": "# express-http-proxy [![NPM version](https://badge.fury.io/js/express-http-proxy.svg)](http://badge.fury.io/js/express-http-proxy) [![Build Status](https://travis-ci.org/villadora/express-http-proxy.svg?branch=master)](https://travis-ci.org/villadora/express-http-proxy) [![Dependency Status](https://gemnasium.com/villadora/express-http-proxy.svg)](https://gemnasium.com/villadora/express-http-proxy)\n\nExpress middleware to proxy request to another host and pass response back to original caller.\n\n## Install\n\n```bash\n$ npm install express-http-proxy --save\n```\n\n## Usage\n```js\nproxy(host, options);\n```\n\n### Example:\nTo proxy URLS starting with '/proxy' to the host 'www.google.com':\n\n```js\nvar proxy = require('express-http-proxy');\nvar app = require('express')();\n\napp.use('/proxy', proxy('www.google.com'));\n```\n\n### Streaming\n\nProxy requests and user responses are piped/streamed/chunked by default.\n\nIf you define a response modifier (userResDecorator, userResHeaderDecorator),\nor need to inspect the response before continuing (maybeSkipToNext), streaming\nis disabled, and the request and response are buffered.\nThis can cause performance issues with large payloads.\n\n### Promises\n\nMany function hooks support Promises.\nIf any Promise is rejected, ```next(x)``` is called in the hosting application, where ```x``` is whatever you pass to ```Promise.reject```;\n\n\ne.g.\n```js\n app.use(proxy('/reject-promise', {\n proxyReqOptDecorator: function() {\n return Promise.reject('An arbitrary rejection message.');\n }\n }));\n```\n\neventually calls\n\n```js\nnext('An arbitrary rejection messasage');\n```\n\n### Host\n\nThe first positional argument is for the proxy host; in many cases you will use a static string here, eg.\n\n```js\napp.use('/', proxy('http://google.com'))\n```\n\nHowever, this argument can also be a function, and that function can be\nmemoized or computed on each request, based on the setting of\n```memoizeHost```.\n\n```js\nfunction selectProxyHost() {\n return (new Date() % 2) ? 'http://google.com' : 'http://altavista.com';\n}\n\napp.use('/', proxy(selectProxyHost));\n```\n\n### Options\n\n#### proxyReqPathResolver (supports Promises)\n\nNote: In ```express-http-proxy```, the ```path``` is considered the portion of\nthe url after the host, and including all query params. E.g. for the URL\n```http://smoogle.com/search/path?q=123```; the path is\n```/search/path?q=123```. Authors using this resolver must also handle the query parameter portion of the path.\n\nProvide a proxyReqPathResolver function if you'd like to\noperate on the path before issuing the proxy request. Use a Promise for async\noperations.\n\n```js\n app.use(proxy('localhost:12345', {\n proxyReqPathResolver: function (req) {\n var parts = req.url.split('?');\n var queryString = parts[1];\n var updatedPath = parts[0].replace(/test/, 'tent');\n return updatedPath + (queryString ? '?' + queryString : '');\n }\n }));\n```\nPromise form\n\n```js\napp.use('/proxy', proxy('localhost:12345', {\n proxyReqPathResolver: function(req) {\n return new Promise(function (resolve, reject) {\n setTimeout(function () { // simulate async\n var parts = req.url.split('?');\n var queryString = parts[1];\n var updatedPath = parts[0].replace(/test/, 'tent');\n var resolvedPathValue = updatedPath + (queryString ? '?' + queryString : '');\n resolve(resolvedPathValue);\n }, 200);\n });\n }\n}));\n```\n\n#### forwardPath\n\nDEPRECATED. See proxyReqPathResolver\n\n#### forwardPathAsync\n\nDEPRECATED. See proxyReqPathResolver\n\n#### filter (supports Promises)\n\nThe ```filter``` option can be used to limit what requests are proxied. Return\n```true``` to continue to execute proxy; return false-y to skip proxy for this\nrequest.\n\nFor example, if you only want to proxy get request:\n\n```js\napp.use('/proxy', proxy('www.google.com', {\n filter: function(req, res) {\n return req.method == 'GET';\n }\n}));\n```\n\nPromise form:\n\n```js\n app.use(proxy('localhost:12346', {\n filter: function (req, res) { \n return new Promise(function (resolve) { \n resolve(req.method === 'GET');\n }); \n }\n }));\n```\n\nNote that in the previous example, `resolve(false)` will execute the happy path\nfor filter here (skipping the rest of the proxy, and calling `next()`).\n`reject()` will also skip the rest of proxy and call `next()`. \n\n#### userResDecorator (was: intercept) (supports Promise)\n\nYou can modify the proxy's response before sending it to the client.\n\n```js\napp.use('/proxy', proxy('www.google.com', {\n userResDecorator: function(proxyRes, proxyResData, userReq, userRes) {\n data = JSON.parse(proxyResData.toString('utf8'));\n data.newProperty = 'exciting data';\n return JSON.stringify(data);\n }\n}));\n```\n\n```js\napp.use(proxy('httpbin.org', {\n userResDecorator: function(proxyRes, proxyResData) {\n return new Promise(function(resolve) {\n proxyResData.funkyMessage = 'oi io oo ii';\n setTimeout(function() {\n resolve(proxyResData);\n }, 200);\n });\n }\n}));\n```\n\n##### 304 - Not Modified\n\nWhen your proxied service returns 304, not modified, this step will be skipped, since there is no body to decorate.\n\n##### exploiting references\nThe intent is that this be used to modify the proxy response data only.\n\nNote:\nThe other arguments (proxyRes, userReq, userRes) are passed by reference, so\nyou *can* currently exploit this to modify either response's headers, for\ninstance, but this is not a reliable interface. I expect to close this\nexploit in a future release, while providing an additional hook for mutating\nthe userRes before sending.\n\n##### gzip responses\n\nIf your proxy response is gzipped, this program will automatically unzip\nit before passing to your function, then zip it back up before piping it to the\nuser response. There is currently no way to short-circuit this behavior.\n\n#### limit\n\nThis sets the body size limit (default: `1mb`). If the body size is larger than the specified (or default) limit,\na `413 Request Entity Too Large` error will be returned. See [bytes.js](https://www.npmjs.com/package/bytes) for\na list of supported formats.\n\n```js\napp.use('/proxy', proxy('www.google.com', {\n limit: '5mb'\n}));\n```\n\n#### memoizeHost\n\nDefaults to ```true```.\n\nWhen true, the ```host``` argument will be parsed on first request, and\nmemoized for subsequent requests.\n\nWhen ```false```, ```host``` argument will be parsed on each request.\n\nE.g.,\n\n```js\n\n function coinToss() { return Math.random() > .5 }\n function getHost() { return coinToss() ? 'http://yahoo.com' : 'http://google.com' }\n\n app.use(proxy(getHost, {\n memoizeHost: false\n }))\n```\n\nIn this example, when ```memoizeHost:false```, the coinToss occurs on each\nrequest, and each request could get either value.\n\nConversely, When ```memoizeHost:true```, the coinToss would occur on the first\nrequest, and all additional requests would return the value resolved on the\nfirst request.\n\n\n### userResHeaderDecorator\n\n```js\napp.use('/proxy', proxy('www.google.com', {\n userResHeaderDecorator(headers, userReq, userRes, proxyReq, proxyRes) {\n // recieves an Object of headers, returns an Object of headers.\n return headers;\n }\n}));\n```\n\n\n#### decorateRequest\n\nREMOVED: See ```proxyReqOptDecorator``` and ```proxyReqBodyDecorator```.\n\n\n#### skipToNextHandlerFilter(supports Promise form)\n(experimental: this interface may change in upcoming versions)\n\nAllows you to inspect the proxy response, and decide if you want to continue processing (via express-http-proxy) or call ```next()``` to return control to express.\n\n```js\napp.use('/proxy', proxy('www.google.com', {\n skipToNextHandlerFilter: function(proxyRes) {\n return proxyRes.statusCode === 404;\n }\n}));\n```\n\n### proxyErrorHandler\n\nBy default, ```express-http-proxy``` will pass any errors except ECONNRESET to\nnext, so that your application can handle or react to them, or just drop\nthrough to your default error handling. ECONNRESET errors are immediately\nreturned to the user for historical reasons.\n\nIf you would like to modify this behavior, you can provide your own ```proxyErrorHandler```.\n\n\n```js\n// Example of skipping all error handling.\n\napp.use(proxy('localhost:12346', {\n proxyErrorHandler: function(err, res, next) {\n next(err);\n }\n}));\n\n\n// Example of rolling your own\n\napp.use(proxy('localhost:12346', {\n proxyErrorHandler: function(err, res, next) {\n switch (err && err.code) {\n case 'ECONNRESET': { return res.status(405).send('504 became 405'); }\n case 'ECONNREFUSED': { return res.status(200).send('gotcher back'); }\n default: { next(err); }\n }\n}}));\n```\n\n\n\n#### proxyReqOptDecorator (supports Promise form)\n\nYou can override most request options before issuing the proxyRequest.\nproxyReqOpt represents the options argument passed to the (http|https).request\nmodule.\n\nNOTE: req.path cannot be changed via this method; use ```proxyReqPathResolver``` instead. (see https://github.com/villadora/express-http-proxy/issues/243)\n\n```js\napp.use('/proxy', proxy('www.google.com', {\n proxyReqOptDecorator: function(proxyReqOpts, srcReq) {\n // you can update headers\n proxyReqOpts.headers['Content-Type'] = 'text/html';\n // you can change the method\n proxyReqOpts.method = 'GET';\n return proxyReqOpts;\n }\n}));\n```\n\nYou can use a Promise for async style.\n\n```js\napp.use('/proxy', proxy('www.google.com', {\n proxyReqOptDecorator: function(proxyReqOpts, srcReq) {\n return new Promise(function(resolve, reject) {\n proxyReqOpts.headers['Content-Type'] = 'text/html';\n resolve(proxyReqOpts);\n })\n }\n}));\n```\n\n#### proxyReqBodyDecorator (supports Promise form)\n\nYou can mutate the body content before sending the proxyRequest.\n\n```js\napp.use('/proxy', proxy('www.google.com', {\n proxyReqBodyDecorator: function(bodyContent, srcReq) {\n return bodyContent.split('').reverse().join('');\n }\n}));\n```\n\nYou can use a Promise for async style.\n\n```js\napp.use('/proxy', proxy('www.google.com', {\n proxyReqBodyDecorator: function(proxyReq, srcReq) {\n return new Promise(function(resolve, reject) {\n http.get('http://dev/null', function (err, res) {\n if (err) { reject(err); }\n resolve(res);\n });\n })\n }\n}));\n```\n\n#### https\n\nNormally, your proxy request will be made on the same protocol as the `host`\nparameter. If you'd like to force the proxy request to be https, use this\noption.\n\n```js\napp.use('/proxy', proxy('www.google.com', {\n https: true\n}));\n```\n\n#### preserveHostHdr\n\nYou can copy the host HTTP header to the proxied express server using the `preserveHostHdr` option.\n\n```js\napp.use('/proxy', proxy('www.google.com', {\n preserveHostHdr: true\n}));\n```\n\n#### parseReqBody\n\nThe ```parseReqBody``` option allows you to control parsing the request body.\nFor example, disabling body parsing is useful for large uploads where it would be inefficient\nto hold the data in memory.\n\n##### Note: this setting is required for binary uploads. A future version of this library may handle this for you.\n\nThis defaults to true in order to preserve legacy behavior.\n\nWhen false, no action will be taken on the body and accordingly ```req.body``` will no longer be set.\n\nNote that setting this to false overrides ```reqAsBuffer``` and ```reqBodyEncoding``` below.\n\n```js\napp.use('/proxy', proxy('www.google.com', {\n parseReqBody: false\n}));\n```\n\n#### reqAsBuffer\n\nNote: this is an experimental feature. ymmv\n\nThe ```reqAsBuffer``` option allows you to ensure the req body is encoded as a Node\n```Buffer``` when sending a proxied request. Any value for this is truthy.\n\nThis defaults to to false in order to preserve legacy behavior. Note that\nthe value of ```reqBodyEnconding``` is used as the encoding when coercing strings\n(and stringified JSON) to Buffer.\n\nIgnored if ```parseReqBody``` is set to false.\n\n```js\napp.use('/proxy', proxy('www.google.com', {\n reqAsBuffer: true\n}));\n```\n\n#### reqBodyEncoding\n\nEncoding used to decode request body. Defaults to ```utf-8```.\n\nUse ```null``` to preserve as Buffer when proxied request body is a Buffer. (e.g image upload)\nAccept any values supported by [raw-body](https://www.npmjs.com/package/raw-body#readme).\n\nThe same encoding is used in the intercept method.\n\nIgnored if ```parseReqBody``` is set to false.\n\n```js\napp.use('/post', proxy('httpbin.org', {\n reqBodyEncoding: null\n}));\n```\n\n#### timeout\n\nBy default, node does not express a timeout on connections.\nUse timeout option to impose a specific timeout.\nTimed-out requests will respond with 504 status code and a X-Timeout-Reason header.\n\n```js\napp.use('/', proxy('httpbin.org', {\n timeout: 2000 // in milliseconds, two seconds\n}));\n```\n\n## Trace debugging\n\nThe node-debug module is used to provide a trace debugging capability.\n\n```\nDEBUG=express-http-proxy npm run YOUR_PROGRAM\nDEBUG=express-http-proxy npm run YOUR_PROGRAM | grep 'express-http-proxy' # to filter down to just these messages\n```\n\nWill trace the execution of the express-http-proxy module in order to aide debugging.\n\n\n\n\n## Upgrade to 1.0, transition guide and breaking changes\n\n1.\n```decorateRequest``` has been REMOVED, and will generate an error when called. See ```proxyReqOptDecorator``` and ```proxyReqBodyDecorator```.\n\nResolution: Most authors will simply need to change the method name for their\ndecorateRequest method; if author was decorating reqOpts and reqBody in the\nsame method, this will need to be split up.\n\n\n2.\n```intercept``` has been REMOVED, and will generate an error when called. See ```userResDecorator```.\n\nResolution: Most authors will simply need to change the method name from ```intercept``` to ```userResDecorator```, and exit the method by returning the value, rather than passing it to a callback. E.g.:\n\nBefore:\n\n```js\napp.use('/proxy', proxy('www.google.com', {\n intercept: function(proxyRes, proxyResData, userReq, userRes, cb) {\n data = JSON.parse(proxyResData.toString('utf8'));\n data.newProperty = 'exciting data';\n cb(null, JSON.stringify(data));\n }\n}));\n```\n\nNow:\n\n```js\napp.use('/proxy', proxy('www.google.com', {\n userResDecorator: function(proxyRes, proxyResData, userReq, userRes) {\n data = JSON.parse(proxyResData.toString('utf8'));\n data.newProperty = 'exciting data';\n return JSON.stringify(data);\n }\n}));\n```\n\n3.\n```forwardPath``` and ```forwardPathAsync``` have been DEPRECATED and will generate a warning when called. See ```proxyReqPathResolver```.\n\nResolution: Simple update the name of either ```forwardPath``` or ```forwardPathAsync``` to ```proxyReqPathResolver```.\n\n## When errors occur on your proxy server\n\nWhen your proxy server responds with an error, express-http-proxy returns a response with the same status code. See ```test/catchingErrors``` for syntax details.\n\nWhen your proxy server times out, express-http-proxy will continue to wait indefinitely for a response, unless you define a ```timeout``` as described above.\n\n\n## Questions\n\n### Q: Does it support https proxy?\n\nThe library will automatically use https if the provided path has 'https://' or ':443'. You may also set option ```https``` to true to always use https.\n\nYou can use ```proxyReqOptDecorator``` to ammend any auth or challenge headers required to succeed https.\n\n### Q: How can I support non-standard certificate chains?\n\nYou can use the ability to decorate the proxy request prior to sending. See ```proxyReqOptDecorator``` for more details.\n\n```js\napp.use('/', proxy('internalhost.example.com', {\n proxyReqOptDecorator: function(proxyReqOpts, originalReq) {\n proxyReqOpts.ca = [caCert, intermediaryCert]\n return proxyReqOpts;\n }\n})\n```\n\n### Q: How to ignore self-signed certificates ?\n\nYou can set the `rejectUnauthorized` value in proxy request options prior to sending. See ```proxyReqOptDecorator``` for more details.\n\n```js\napp.use('/', proxy('internalhost.example.com', {\n proxyReqOptDecorator: function(proxyReqOpts, originalReq) {\n proxyReqOpts.rejectUnauthorized = false\n return proxyReqOpts;\n }\n}))\n```\n\n\n## Release Notes\n\n| Release | Notes |\n| --- | --- |\n| 1.6.0 | Do gzip and gunzip aysyncronously. Test and documentation improvements, dependency updates. |\n| 1.5.1 | Fixes bug in stringifying debug messages. |\n| 1.5.0 | Fixes bug in `filter` signature. Fix bug in skipToNextHandler, add expressHttpProxy value to user res when skipped. Add tests for host as ip address. |\n| 1.4.0 | DEPRECATED. Critical bug in the `filter` api.| \n| 1.3.0 | DEPRECATED. Critical bug in the `filter` api. `filter` now supports Promises. Update linter to eslint. |\n| 1.2.0 | Auto-stream when no decorations are made to req/res. Improved docs, fixes issues in maybeSkipToNexthandler, allow authors to manage error handling. | \n| 1.1.0 | Add step to allow response headers to be modified.\n| 1.0.7 | Update dependencies. Improve docs on promise rejection. Fix promise rejection on body limit. Improve debug output. |\n| 1.0.6 | Fixes preserveHostHdr not working, skip userResDecorator on 304, add maybeSkipToNext, test improvements and cleanup. |\n| 1.0.5 | Minor documentation and test patches |\n| 1.0.4 | Minor documentation, test, and package fixes |\n| 1.0.3 | Fixes 'limit option is not taken into account |\n| 1.0.2 | Minor docs corrections. |\n| 1.0.1 | Minor docs adjustments. |\n| 1.0.0 | Major revision.
REMOVE decorateRequest, ADD proxyReqOptDecorator and proxyReqBodyDecorator.
REMOVE intercept, ADD userResDecorator
userResDecorator supports a Promise form for async operations.
General cleanup of structure and application of hooks. Documentation improvements. Update all dependencies. Re-organize code as a series of workflow steps, each (potentially) supporting a promise, and creating a reusable pattern for future development. |\n| 0.11.0 | Allow author to prevent host from being memoized between requests. General program cleanup. |\n| 0.10.1| Fixed issue where 'body encoding' was being incorrectly set to the character encoding.
Dropped explicit support for node 0.10.
Intercept can now deal with gziped responses.
Author can now 'force https', even if the original request is over http.
Do not call next after ECONNRESET catch. |\n| 0.10.0 | Fix regression in forwardPath implementation. |\n| 0.9.1 | Documentation updates. Set 'Accept-Encoding' header to match bodyEncoding. |\n| 0.9.0 | Better handling for request body when body is JSON. |\n| 0.8.0 | Features: add forwardPathAsync option
Updates: modernize dependencies
Fixes: Exceptions parsing proxied response causes error: Can't set headers after they are sent. (#111)
If client request aborts, proxied request is aborted too (#107) |\n| 0.7.4 | Move jscs to devDependencies to avoid conflict with nsp. |\n| 0.7.3 | Adds a timeout option. Code organization and small bug fixes. |\n| 0.7.2 | Collecting many minor documentation and test improvements. |\n| 0.4.0 | Signature of `intercept` callback changed from `function(data, req, res, callback)` to `function(rsp, data, req, res, callback)` where `rsp` is the original response from the target |\n\n## Licence\n\nMIT\n\n", + "readmeFilename": "README.md", "repository": { "type": "git", "url": "git://github.com/villadora/express-http-proxy.git" diff --git a/node_modules/http-proxy-middleware/package.json b/node_modules/http-proxy-middleware/package.json index 2ed94c0c9..cb5f2fa14 100644 --- a/node_modules/http-proxy-middleware/package.json +++ b/node_modules/http-proxy-middleware/package.json @@ -6,14 +6,14 @@ "_location": "/http-proxy-middleware", "_phantomChildren": {}, "_requested": { - "type": "tag", - "registry": true, - "raw": "http-proxy-middleware", - "name": "http-proxy-middleware", "escapedName": "http-proxy-middleware", + "fetchSpec": "latest", + "name": "http-proxy-middleware", + "raw": "http-proxy-middleware", "rawSpec": "", + "registry": true, "saveSpec": null, - "fetchSpec": "latest" + "type": "tag" }, "_requiredBy": [ "#DEV:/", @@ -21,6 +21,7 @@ ], "_resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-1.0.1.tgz", "_shasum": "a87ee6564991faca4844ae4ab1cf4221279c28f0", + "_shrinkwrap": null, "_spec": "http-proxy-middleware", "_where": "C:\\Users\\Administrator\\Documents\\project\\hc\\MicrCommunityWeb", "author": { @@ -85,24 +86,27 @@ } }, "keywords": [ - "reverse", - "proxy", - "middleware", + "browser-sync", + "connect", + "cors", + "express", + "grunt-contrib-connect", + "gulp", "http", "https", - "connect", - "express", + "middleware", "polka", - "browser-sync", - "gulp", - "grunt-contrib-connect", + "proxy", + "reverse", "websocket", - "ws", - "cors" + "ws" ], "license": "MIT", "main": "dist/index.js", "name": "http-proxy-middleware", + "optionalDependencies": {}, + "readme": "# http-proxy-middleware\n\n[![Build Status](https://img.shields.io/travis/chimurai/http-proxy-middleware/master.svg?style=flat-square)](https://travis-ci.org/chimurai/http-proxy-middleware)\n[![Coveralls](https://img.shields.io/coveralls/chimurai/http-proxy-middleware.svg?style=flat-square)](https://coveralls.io/r/chimurai/http-proxy-middleware)\n[![dependency Status](https://img.shields.io/david/chimurai/http-proxy-middleware.svg?style=flat-square)](https://david-dm.org/chimurai/http-proxy-middleware#info=dependencies)\n[![dependency Status](https://snyk.io/test/npm/http-proxy-middleware/badge.svg?style=flat-square)](https://snyk.io/test/npm/http-proxy-middleware)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\nNode.js proxying made simple. Configure proxy middleware with ease for [connect](https://github.com/senchalabs/connect), [express](https://github.com/strongloop/express), [browser-sync](https://github.com/BrowserSync/browser-sync) and [many more](#compatible-servers).\n\nPowered by the popular Nodejitsu [`http-proxy`](https://github.com/nodejitsu/node-http-proxy). [![GitHub stars](https://img.shields.io/github/stars/nodejitsu/node-http-proxy.svg?style=social&label=Star)](https://github.com/nodejitsu/node-http-proxy)\n\n## ⚠️ Note\n\nThis page is showing documentation for version v1.x.x ([release notes](https://github.com/chimurai/http-proxy-middleware/releases))\n\nIf you're looking for v0.x documentation. Go to:\nhttps://github.com/chimurai/http-proxy-middleware/tree/v0.21.0#readme\n\n## TL;DR\n\nProxy `/api` requests to `http://www.example.org`\n\n```javascript\n// javascript\n\nconst express = require('express');\nconst { createProxyMiddleware } = require('http-proxy-middleware');\n\nconst app = express();\n\napp.use('/api', createProxyMiddleware({ target: 'http://www.example.org', changeOrigin: true }));\napp.listen(3000);\n\n// http://localhost:3000/api/foo/bar -> http://www.example.org/api/foo/bar\n```\n\n```typescript\n// typescript\n\nimport * as express from 'express';\nimport { createProxyMiddleware, Filter, Options, RequestHandler } from 'http-proxy-middleware';\n\nconst app = express();\n\napp.use('/api', createProxyMiddleware({ target: 'http://www.example.org', changeOrigin: true }));\napp.listen(3000);\n\n// http://localhost:3000/api/foo/bar -> http://www.example.org/api/foo/bar\n```\n\n_All_ `http-proxy` [options](https://github.com/nodejitsu/node-http-proxy#options) can be used, along with some extra `http-proxy-middleware` [options](#options).\n\n:bulb: **Tip:** Set the option `changeOrigin` to `true` for [name-based virtual hosted sites](http://en.wikipedia.org/wiki/Virtual_hosting#Name-based).\n\n## Table of Contents\n\n\n\n- [Install](#install)\n- [Core concept](#core-concept)\n- [Example](#example)\n- [Context matching](#context-matching)\n- [Options](#options)\n - [http-proxy-middleware options](#http-proxy-middleware-options)\n - [http-proxy events](#http-proxy-events)\n - [http-proxy options](#http-proxy-options)\n- [Shorthand](#shorthand)\n - [app.use\\(path, proxy\\)](#appusepath-proxy)\n- [WebSocket](#websocket)\n - [External WebSocket upgrade](#external-websocket-upgrade)\n- [Working examples](#working-examples)\n- [Recipes](#recipes)\n- [Compatible servers](#compatible-servers)\n- [Tests](#tests)\n- [Changelog](#changelog)\n- [License](#license)\n\n\n\n## Install\n\n```bash\n$ npm install --save-dev http-proxy-middleware\n```\n\n## Core concept\n\nProxy middleware configuration.\n\n#### createProxyMiddleware([context,] config)\n\n```javascript\nconst { createProxyMiddleware } = require('http-proxy-middleware');\n\nconst apiProxy = createProxyMiddleware('/api', { target: 'http://www.example.org' });\n// \\____/ \\_____________________________/\n// | |\n// context options\n\n// 'apiProxy' is now ready to be used as middleware in a server.\n```\n\n- **context**: Determine which requests should be proxied to the target host.\n (more on [context matching](#context-matching))\n- **options.target**: target host to proxy to. _(protocol + host)_\n\n(full list of [`http-proxy-middleware` configuration options](#options))\n\n#### createProxyMiddleware(uri [, config])\n\n```javascript\n// shorthand syntax for the example above:\nconst apiProxy = createProxyMiddleware('http://www.example.org/api');\n```\n\nMore about the [shorthand configuration](#shorthand).\n\n## Example\n\nAn example with `express` server.\n\n```javascript\n// include dependencies\nconst express = require('express');\nconst { createProxyMiddleware } = require('http-proxy-middleware');\n\n// proxy middleware options\nconst options = {\n target: 'http://www.example.org', // target host\n changeOrigin: true, // needed for virtual hosted sites\n ws: true, // proxy websockets\n pathRewrite: {\n '^/api/old-path': '/api/new-path', // rewrite path\n '^/api/remove/path': '/path' // remove base path\n },\n router: {\n // when request.headers.host == 'dev.localhost:3000',\n // override target 'http://www.example.org' to 'http://localhost:8000'\n 'dev.localhost:3000': 'http://localhost:8000'\n }\n};\n\n// create the proxy (without context)\nconst exampleProxy = createProxyMiddleware(options);\n\n// mount `exampleProxy` in web server\nconst app = express();\napp.use('/api', exampleProxy);\napp.listen(3000);\n```\n\n## Context matching\n\nProviding an alternative way to decide which requests should be proxied; In case you are not able to use the server's [`path` parameter](http://expressjs.com/en/4x/api.html#app.use) to mount the proxy or when you need more flexibility.\n\n[RFC 3986 `path`](https://tools.ietf.org/html/rfc3986#section-3.3) is used for context matching.\n\n```ascii\n foo://example.com:8042/over/there?name=ferret#nose\n \\_/ \\______________/\\_________/ \\_________/ \\__/\n | | | | |\n scheme authority path query fragment\n```\n\n- **path matching**\n\n - `createProxyMiddleware({...})` - matches any path, all requests will be proxied.\n - `createProxyMiddleware('/', {...})` - matches any path, all requests will be proxied.\n - `createProxyMiddleware('/api', {...})` - matches paths starting with `/api`\n\n- **multiple path matching**\n\n - `createProxyMiddleware(['/api', '/ajax', '/someotherpath'], {...})`\n\n- **wildcard path matching**\n\n For fine-grained control you can use wildcard matching. Glob pattern matching is done by _micromatch_. Visit [micromatch](https://www.npmjs.com/package/micromatch) or [glob](https://www.npmjs.com/package/glob) for more globbing examples.\n\n - `createProxyMiddleware('**', {...})` matches any path, all requests will be proxied.\n - `createProxyMiddleware('**/*.html', {...})` matches any path which ends with `.html`\n - `createProxyMiddleware('/*.html', {...})` matches paths directly under path-absolute\n - `createProxyMiddleware('/api/**/*.html', {...})` matches requests ending with `.html` in the path of `/api`\n - `createProxyMiddleware(['/api/**', '/ajax/**'], {...})` combine multiple patterns\n - `createProxyMiddleware(['/api/**', '!**/bad.json'], {...})` exclusion\n\n **Note**: In multiple path matching, you cannot use string paths and wildcard paths together.\n\n- **custom matching**\n\n For full control you can provide a custom function to determine which requests should be proxied or not.\n\n ```javascript\n /**\n * @return {Boolean}\n */\n const filter = function(pathname, req) {\n return pathname.match('^/api') && req.method === 'GET';\n };\n\n const apiProxy = createProxyMiddleware(filter, {\n target: 'http://www.example.org'\n });\n ```\n\n## Options\n\n### http-proxy-middleware options\n\n- **option.pathRewrite**: object/function, rewrite target's url path. Object-keys will be used as _RegExp_ to match paths.\n\n ```javascript\n // rewrite path\n pathRewrite: {'^/old/api' : '/new/api'}\n\n // remove path\n pathRewrite: {'^/remove/api' : ''}\n\n // add base path\n pathRewrite: {'^/' : '/basepath/'}\n\n // custom rewriting\n pathRewrite: function (path, req) { return path.replace('/api', '/base/api') }\n\n // custom rewriting, returning Promise\n pathRewrite: async function (path, req) {\n const should_add_something = await httpRequestToDecideSomething(path);\n if (should_add_something) path += \"something\";\n return path;\n }\n ```\n\n- **option.router**: object/function, re-target `option.target` for specific requests.\n\n ```javascript\n // Use `host` and/or `path` to match requests. First match will be used.\n // The order of the configuration matters.\n router: {\n 'integration.localhost:3000' : 'http://localhost:8001', // host only\n 'staging.localhost:3000' : 'http://localhost:8002', // host only\n 'localhost:3000/api' : 'http://localhost:8003', // host + path\n '/rest' : 'http://localhost:8004' // path only\n }\n\n // Custom router function (string target)\n router: function(req) {\n return 'http://localhost:8004';\n }\n\n // Custom router function (target object)\n router: function(req) {\n return {\n protocol: 'https:', // The : is required\n host: 'localhost',\n port: 8004\n };\n }\n\n // Asynchronous router function which returns promise\n router: async function(req) {\n const url = await doSomeIO();\n return url;\n }\n ```\n\n- **option.logLevel**: string, ['debug', 'info', 'warn', 'error', 'silent']. Default: `'info'`\n\n- **option.logProvider**: function, modify or replace log provider. Default: `console`.\n\n ```javascript\n // simple replace\n function logProvider(provider) {\n // replace the default console log provider.\n return require('winston');\n }\n ```\n\n ```javascript\n // verbose replacement\n function logProvider(provider) {\n const logger = new (require('winston').Logger)();\n\n const myCustomProvider = {\n log: logger.log,\n debug: logger.debug,\n info: logger.info,\n warn: logger.warn,\n error: logger.error\n };\n return myCustomProvider;\n }\n ```\n\n### http-proxy events\n\nSubscribe to [http-proxy events](https://github.com/nodejitsu/node-http-proxy#listening-for-proxy-events):\n\n- **option.onError**: function, subscribe to http-proxy's `error` event for custom error handling.\n\n ```javascript\n function onError(err, req, res) {\n res.writeHead(500, {\n 'Content-Type': 'text/plain'\n });\n res.end('Something went wrong. And we are reporting a custom error message.');\n }\n ```\n\n- **option.onProxyRes**: function, subscribe to http-proxy's `proxyRes` event.\n\n ```javascript\n function onProxyRes(proxyRes, req, res) {\n proxyRes.headers['x-added'] = 'foobar'; // add new header to response\n delete proxyRes.headers['x-removed']; // remove header from response\n }\n ```\n\n- **option.onProxyReq**: function, subscribe to http-proxy's `proxyReq` event.\n\n ```javascript\n function onProxyReq(proxyReq, req, res) {\n // add custom header to request\n proxyReq.setHeader('x-added', 'foobar');\n // or log the req\n }\n ```\n\n- **option.onProxyReqWs**: function, subscribe to http-proxy's `proxyReqWs` event.\n\n ```javascript\n function onProxyReqWs(proxyReq, req, socket, options, head) {\n // add custom header\n proxyReq.setHeader('X-Special-Proxy-Header', 'foobar');\n }\n ```\n\n- **option.onOpen**: function, subscribe to http-proxy's `open` event.\n\n ```javascript\n function onOpen(proxySocket) {\n // listen for messages coming FROM the target here\n proxySocket.on('data', hybiParseAndLogMessage);\n }\n ```\n\n- **option.onClose**: function, subscribe to http-proxy's `close` event.\n\n ```javascript\n function onClose(res, socket, head) {\n // view disconnected websocket connections\n console.log('Client disconnected');\n }\n ```\n\n### http-proxy options\n\nThe following options are provided by the underlying [http-proxy](https://github.com/nodejitsu/node-http-proxy#options) library.\n\n- **option.target**: url string to be parsed with the url module\n- **option.forward**: url string to be parsed with the url module\n- **option.agent**: object to be passed to http(s).request (see Node's [https agent](http://nodejs.org/api/https.html#https_class_https_agent) and [http agent](http://nodejs.org/api/http.html#http_class_http_agent) objects)\n- **option.ssl**: object to be passed to https.createServer()\n- **option.ws**: true/false: if you want to proxy websockets\n- **option.xfwd**: true/false, adds x-forward headers\n- **option.secure**: true/false, if you want to verify the SSL Certs\n- **option.toProxy**: true/false, passes the absolute URL as the `path` (useful for proxying to proxies)\n- **option.prependPath**: true/false, Default: true - specify whether you want to prepend the target's path to the proxy path\n- **option.ignorePath**: true/false, Default: false - specify whether you want to ignore the proxy path of the incoming request (note: you will have to append / manually if required).\n- **option.localAddress** : Local interface string to bind for outgoing connections\n- **option.changeOrigin**: true/false, Default: false - changes the origin of the host header to the target URL\n- **option.preserveHeaderKeyCase**: true/false, Default: false - specify whether you want to keep letter case of response header key\n- **option.auth** : Basic authentication i.e. 'user:password' to compute an Authorization header.\n- **option.hostRewrite**: rewrites the location hostname on (301/302/307/308) redirects.\n- **option.autoRewrite**: rewrites the location host/port on (301/302/307/308) redirects based on requested host/port. Default: false.\n- **option.protocolRewrite**: rewrites the location protocol on (301/302/307/308) redirects to 'http' or 'https'. Default: null.\n- **option.cookieDomainRewrite**: rewrites domain of `set-cookie` headers. Possible values:\n - `false` (default): disable cookie rewriting\n - String: new domain, for example `cookieDomainRewrite: \"new.domain\"`. To remove the domain, use `cookieDomainRewrite: \"\"`.\n - Object: mapping of domains to new domains, use `\"*\"` to match all domains. \n For example keep one domain unchanged, rewrite one domain and remove other domains:\n ```json\n cookieDomainRewrite: {\n \"unchanged.domain\": \"unchanged.domain\",\n \"old.domain\": \"new.domain\",\n \"*\": \"\"\n }\n ```\n- **option.cookiePathRewrite**: rewrites path of `set-cookie` headers. Possible values:\n - `false` (default): disable cookie rewriting\n - String: new path, for example `cookiePathRewrite: \"/newPath/\"`. To remove the path, use `cookiePathRewrite: \"\"`. To set path to root use `cookiePathRewrite: \"/\"`.\n - Object: mapping of paths to new paths, use `\"*\"` to match all paths.\n For example, to keep one path unchanged, rewrite one path and remove other paths:\n ```json\n cookiePathRewrite: {\n \"/unchanged.path/\": \"/unchanged.path/\",\n \"/old.path/\": \"/new.path/\",\n \"*\": \"\"\n }\n ```\n- **option.headers**: object, adds [request headers](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields). (Example: `{host:'www.example.org'}`)\n- **option.proxyTimeout**: timeout (in millis) when proxy receives no response from target\n- **option.timeout**: timeout (in millis) for incoming requests\n- **option.followRedirects**: true/false, Default: false - specify whether you want to follow redirects\n- **option.selfHandleResponse** true/false, if set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the `proxyRes` event\n- **option.buffer**: stream of data to send as the request body. Maybe you have some middleware that consumes the request stream before proxying it on e.g. If you read the body of a request into a field called 'req.rawbody' you could restream this field in the buffer option:\n\n ```javascript\n 'use strict';\n\n const streamify = require('stream-array');\n const HttpProxy = require('http-proxy');\n const proxy = new HttpProxy();\n\n module.exports = (req, res, next) => {\n proxy.web(\n req,\n res,\n {\n target: 'http://localhost:4003/',\n buffer: streamify(req.rawBody)\n },\n next\n );\n };\n ```\n\n## Shorthand\n\nUse the shorthand syntax when verbose configuration is not needed. The `context` and `option.target` will be automatically configured when shorthand is used. Options can still be used if needed.\n\n```javascript\ncreateProxyMiddleware('http://www.example.org:8000/api');\n// createProxyMiddleware('/api', {target: 'http://www.example.org:8000'});\n\ncreateProxyMiddleware('http://www.example.org:8000/api/books/*/**.json');\n// createProxyMiddleware('/api/books/*/**.json', {target: 'http://www.example.org:8000'});\n\ncreateProxyMiddleware('http://www.example.org:8000/api', { changeOrigin: true });\n// createProxyMiddleware('/api', {target: 'http://www.example.org:8000', changeOrigin: true});\n```\n\n### app.use(path, proxy)\n\nIf you want to use the server's `app.use` `path` parameter to match requests;\nCreate and mount the proxy without the http-proxy-middleware `context` parameter:\n\n```javascript\napp.use('/api', createProxyMiddleware({ target: 'http://www.example.org', changeOrigin: true }));\n```\n\n`app.use` documentation:\n\n- express: http://expressjs.com/en/4x/api.html#app.use\n- connect: https://github.com/senchalabs/connect#mount-middleware\n- polka: https://github.com/lukeed/polka#usebase-fn\n\n## WebSocket\n\n```javascript\n// verbose api\ncreateProxyMiddleware('/', { target: 'http://echo.websocket.org', ws: true });\n\n// shorthand\ncreateProxyMiddleware('http://echo.websocket.org', { ws: true });\n\n// shorter shorthand\ncreateProxyMiddleware('ws://echo.websocket.org');\n```\n\n### External WebSocket upgrade\n\nIn the previous WebSocket examples, http-proxy-middleware relies on a initial http request in order to listen to the http `upgrade` event. If you need to proxy WebSockets without the initial http request, you can subscribe to the server's http `upgrade` event manually.\n\n```javascript\nconst wsProxy = createProxyMiddleware('ws://echo.websocket.org', { changeOrigin: true });\n\nconst app = express();\napp.use(wsProxy);\n\nconst server = app.listen(3000);\nserver.on('upgrade', wsProxy.upgrade); // <-- subscribe to http 'upgrade'\n```\n\n## Working examples\n\nView and play around with [working examples](https://github.com/chimurai/http-proxy-middleware/tree/master/examples).\n\n- Browser-Sync ([example source](https://github.com/chimurai/http-proxy-middleware/tree/master/examples/browser-sync/index.js))\n- express ([example source](https://github.com/chimurai/http-proxy-middleware/tree/master/examples/express/index.js))\n- connect ([example source](https://github.com/chimurai/http-proxy-middleware/tree/master/examples/connect/index.js))\n- WebSocket ([example source](https://github.com/chimurai/http-proxy-middleware/tree/master/examples/websocket/index.js))\n\n## Recipes\n\nView the [recipes](https://github.com/chimurai/http-proxy-middleware/tree/master/recipes) for common use cases.\n\n## Compatible servers\n\n`http-proxy-middleware` is compatible with the following servers:\n\n- [connect](https://www.npmjs.com/package/connect)\n- [express](https://www.npmjs.com/package/express)\n- [browser-sync](https://www.npmjs.com/package/browser-sync)\n- [lite-server](https://www.npmjs.com/package/lite-server)\n- [polka](https://github.com/lukeed/polka)\n- [grunt-contrib-connect](https://www.npmjs.com/package/grunt-contrib-connect)\n- [grunt-browser-sync](https://www.npmjs.com/package/grunt-browser-sync)\n- [gulp-connect](https://www.npmjs.com/package/gulp-connect)\n- [gulp-webserver](https://www.npmjs.com/package/gulp-webserver)\n\nSample implementations can be found in the [server recipes](https://github.com/chimurai/http-proxy-middleware/tree/master/recipes/servers.md).\n\n## Tests\n\nRun the test suite:\n\n```bash\n# install dependencies\n$ yarn\n\n# linting\n$ yarn lint\n$ yarn lint:fix\n\n# building (compile typescript to js)\n$ yarn build\n\n# unit tests\n$ yarn test\n\n# code coverage\n$ yarn cover\n```\n\n## Changelog\n\n- [View changelog](https://github.com/chimurai/http-proxy-middleware/blob/master/CHANGELOG.md)\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2015-2020 Steven Chim\n", + "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/chimurai/http-proxy-middleware.git" diff --git a/public/admin.html b/public/admin.html index 46afbe3db..faa4dd6af 100644 --- a/public/admin.html +++ b/public/admin.html @@ -41,6 +41,9 @@ + + + diff --git a/public/vcCore/vcFramework.js b/public/vcCore/vcFramework.js index 0b26b797d..7d3ddcd63 100644 --- a/public/vcCore/vcFramework.js +++ b/public/vcCore/vcFramework.js @@ -258,7 +258,11 @@ let _vcCreateEl = document.getElementById(_tree.treeId); let _componentHeader = _tree.html.getElementsByTagName('head'); let _componentBody = _tree.html.getElementsByTagName('body'); + if(_vcCreateEl == null){ + console.log('vcCreate',_vcCreateEl,_tree.treeId,_tree); + } + if (_vcCreateEl.hasAttribute("location") && 'head' == _vcCreateEl.getAttribute('location')) { let _componentHs = _componentHeader[0].childNodes; _header[0].appendChild(_componentHeader[0]); @@ -280,9 +284,17 @@ } } else { - _vcCreateEl.innerHTML = _componentBody[0].innerHTML; + //_vcCreateEl.innerHTML = _componentBody[0].innerHTML; //_vcCreateEl.parentNode.replaceChild(_componentBody[0], _vcCreateEl); + for(let _comBodyIndex = 0 ; _comBodyIndex < _componentBody.length; _comBodyIndex ++){ + let _childNodes = _componentBody[_comBodyIndex].childNodes; + for(let _tmpChildIndex = 0 ; _tmpChildIndex < _childNodes.length; _tmpChildIndex ++){ + _vcCreateEl.parentNode.insertBefore(_childNodes[_tmpChildIndex],_vcCreateEl) + } + + } + } //将js 脚本放到 组件 脚本中 if (vcFramework.isNotEmpty(_tree.js)) {