@podium/proxy
Advanced tools
Comparing version 5.0.15 to 5.0.16
@@ -0,1 +1,8 @@ | ||
## [5.0.16](https://github.com/podium-lib/proxy/compare/v5.0.15...v5.0.16) (2024-05-14) | ||
### Bug Fixes | ||
* generate type definitions from JSDoc ([#293](https://github.com/podium-lib/proxy/issues/293)) ([fd365b2](https://github.com/podium-lib/proxy/commit/fd365b2c5df70d3910fd1e41be7973a3eebb0141)) | ||
## [5.0.15](https://github.com/podium-lib/proxy/compare/v5.0.14...v5.0.15) (2024-05-14) | ||
@@ -2,0 +9,0 @@ |
@@ -9,2 +9,11 @@ import { pathToRegexp } from 'path-to-regexp'; | ||
/** | ||
* @typedef {object} PodiumProxyOptions | ||
* @property {string} [pathname="/"] | ||
* @property {string} [prefix="/podium-resource"] | ||
* @property {number} [timeout=20000] | ||
* @property {number} [maxAge=Infinity] | ||
* @property {import('abslog').AbstractLoggerOptions | null} [logger=null] | ||
*/ | ||
export default class PodiumProxy { | ||
@@ -20,2 +29,7 @@ #pathname; | ||
#pathnameParser; | ||
/** | ||
* @constructor | ||
* @param {PodiumProxyOptions} options | ||
*/ | ||
constructor({ | ||
@@ -32,14 +46,17 @@ pathname = '/', | ||
this.#pathnameEntries = []; | ||
this.#pathnameParser = pathToRegexp(utils.pathnameBuilder( | ||
this.#pathname, | ||
this.#prefix, | ||
':podiumPodletName', | ||
':podiumProxyName', | ||
':podiumProxyExtras*', | ||
), this.#pathnameEntries); | ||
this.#pathnameParser = pathToRegexp( | ||
utils.pathnameBuilder( | ||
this.#pathname, | ||
this.#prefix, | ||
':podiumPodletName', | ||
':podiumProxyName', | ||
':podiumProxyExtras*', | ||
), | ||
this.#pathnameEntries, | ||
); | ||
// eslint-disable-next-line new-cap | ||
this.#proxy = new Proxy.createProxy({ | ||
this.#proxy = Proxy.createProxy({ | ||
proxyTimeout: timeout, | ||
}); | ||
this.#proxy.on('error', (error) => { | ||
@@ -90,3 +107,8 @@ this.#log.error( | ||
register(name = '', manifest = {}) { | ||
/** | ||
* Register a podlet in the proxy. This will read the proxy configuration from the manifest. | ||
* @param {string} name | ||
* @param {import('@podium/schemas').PodletManifestSchema} manifest | ||
*/ | ||
register(name, manifest) { | ||
if (schemas.name(name).error) | ||
@@ -124,3 +146,3 @@ throw new Error( | ||
this.#registry.set(`${name}/${key}`, obj.proxy[key]); | ||
const path = utils.pathnameBuilder( | ||
@@ -139,2 +161,6 @@ this.#pathname, | ||
/** | ||
* @param {import('@podium/utils').HttpIncoming} incoming | ||
* @returns {Promise<import('@podium/utils').HttpIncoming | undefined>} The incoming request with the `.proxy` property set to true if successfully proxied, or `undefined` if the incoming request didn't match anything registered in the proxy. | ||
*/ | ||
process(incoming) { | ||
@@ -273,2 +299,2 @@ if ( | ||
} | ||
}; | ||
} |
{ | ||
"name": "@podium/proxy", | ||
"version": "5.0.15", | ||
"version": "5.0.16", | ||
"description": "Transparent http proxy. Dynamically mounts proxy targets on an existing HTTP server instance.", | ||
@@ -25,19 +25,19 @@ "type": "module", | ||
"CHANGELOG.md", | ||
"proxy.d.ts", | ||
"README.md", | ||
"LICENSE", | ||
"dist", | ||
"lib" | ||
"lib", | ||
"types" | ||
], | ||
"main": "./lib/proxy.js", | ||
"types": "./proxy.d.ts", | ||
"types": "./types/proxy.d.ts", | ||
"scripts": { | ||
"lint": "eslint .", | ||
"lint:fix": "eslint --fix .", | ||
"test": "tap tests/*.js --disable-coverage --allow-empty-coverage" | ||
"test": "tap tests/*.js --disable-coverage --allow-empty-coverage && tsc --project tsconfig.test.json", | ||
"types": "tsc --declaration --emitDeclarationOnly" | ||
}, | ||
"dependencies": { | ||
"@metrics/client": "2.5.2", | ||
"@podium/schemas": "5.0.2", | ||
"@podium/utils": "5.0.6", | ||
"@metrics/client": "2.5.2", | ||
"abslog": "2.4.4", | ||
@@ -49,2 +49,3 @@ "http-proxy": "1.18.1", | ||
"@babel/eslint-parser": "7.24.5", | ||
"@podium/test-utils": "2.5.2", | ||
"@semantic-release/changelog": "6.0.3", | ||
@@ -56,4 +57,4 @@ "@semantic-release/commit-analyzer": "11.1.0", | ||
"@semantic-release/release-notes-generator": "12.1.0", | ||
"semantic-release": "23.0.8", | ||
"@podium/test-utils": "2.5.2", | ||
"@types/http-proxy": "1.17.14", | ||
"@types/readable-stream": "^4.0.12", | ||
"eslint": "8.57.0", | ||
@@ -65,4 +66,6 @@ "eslint-config-airbnb-base": "15.0.0", | ||
"prettier": "3.2.5", | ||
"tap": "18.7.2" | ||
"semantic-release": "23.0.8", | ||
"tap": "18.7.2", | ||
"typescript": "5.4.5" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69206
19
296