@entur-partner/bff 1.2.11 → 1.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/forwardingproxy.d.ts +1 -0
- package/dist/forwardingproxy.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +16 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +16 -21
- package/dist/bff.cjs.development.js +0 -43
- package/dist/bff.cjs.development.js.map +0 -1
- package/dist/bff.cjs.production.min.js +0 -2
- package/dist/bff.cjs.production.min.js.map +0 -1
- package/dist/bff.esm.js +0 -38
- package/dist/bff.esm.js.map +0 -1
- package/dist/index.js +0 -8
|
@@ -13,3 +13,4 @@ export type ForwardingProxyType = {
|
|
|
13
13
|
* @returns Proxy middleware function
|
|
14
14
|
*/
|
|
15
15
|
export declare const forwardingProxy: (apiUrl: string) => (method: ForwardingProxyType["method"], forwardPath: ForwardingProxyType["forwardPath"], proxyReqOptDecorator?: ForwardingProxyType["proxyReqOptDecorator"]) => import("express").RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
16
|
+
//# sourceMappingURL=forwardingproxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forwardingproxy.d.ts","sourceRoot":"","sources":["../src/forwardingproxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAK9D,eAAO,MAAM,WAAW,GACvB,SAAS,MAAM,EAAE,EACjB,sBAAsB,QAAQ,CAAC,YAAY,CAAC,CAAC,sBAAsB,CAAC,EACpE,uBAAuB,QAAQ,CAAC,YAAY,CAAC,CAAC,sBAAsB,CAAC,KACnE,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAW5B,CAAC;AAKF,MAAM,MAAM,mBAAmB,GAAG;IACjC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,MAAM,CAAC;IAC5C,oBAAoB,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC,sBAAsB,CAAC,CAAC;CACtE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAC1B,QAAQ,MAAM,MAEd,QAAQ,mBAAmB,CAAC,QAAQ,CAAC,EACrC,aAAa,mBAAmB,CAAC,aAAa,CAAC,EAC/C,uBAAuB,mBAAmB,CAAC,sBAAsB,CAAC,iJAUjE,CAAC"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`express-http-proxy`);c=s(c,1);var l=e=>/(^undefined$)|(^Bearer .+$)/gim.test(e.headers.authorization||``),u=(e,t,n)=>{let r=Array.isArray(e)?e:[e];return{filter:e=>r.includes(e.method)&&l(e),proxyReqPathResolver:t,proxyReqOptDecorator:n,proxyReqBodyDecorator:(e,t)=>e,limit:`${process.env.UPLOAD_LIMIT_MB||200}mb`}},d=e=>e.endsWith(`/`)?e.substring(0,e.length-1):e,f=e=>(t,n,r)=>(0,c.default)(e,u(t,(...t)=>d(new URL(e).pathname)+n(...t),r));exports.forwardingProxy=f,exports.proxyConfig=u;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/forwardingproxy.ts"],"sourcesContent":["import type { Request } from \"express\";\nimport proxy, { type ProxyOptions } from \"express-http-proxy\";\n\nconst requireOAuth = (req: Request) =>\n\t/(^undefined$)|(^Bearer .+$)/gim.test(req.headers.authorization || \"\");\n\nexport const proxyConfig = (\n\tmethods: string[],\n\tproxyReqPathResolver: Required<ProxyOptions>[\"proxyReqPathResolver\"],\n\tproxyReqOptDecorator?: Required<ProxyOptions>[\"proxyReqOptDecorator\"],\n): Parameters<typeof proxy>[1] => {\n\tconst httpMethods = Array.isArray(methods) ? methods : [methods];\n\n\treturn {\n\t\tfilter: (req: Request) =>\n\t\t\thttpMethods.includes(req.method) && requireOAuth(req),\n\t\tproxyReqPathResolver,\n\t\tproxyReqOptDecorator,\n\t\tproxyReqBodyDecorator: (bodyContent, _srcReq) => bodyContent,\n\t\tlimit: `${process.env.UPLOAD_LIMIT_MB || 200}mb`,\n\t};\n};\n\nconst stripTrailingSlash = (url: string) =>\n\turl.endsWith(\"/\") ? url.substring(0, url.length - 1) : url;\n\nexport type ForwardingProxyType = {\n\tmethod: string[];\n\tforwardPath: (...reqs: Request[]) => string;\n\tproxyReqOptDecorator?: Required<ProxyOptions>[\"proxyReqOptDecorator\"];\n};\n\n/**\n * Creates a forwarding proxy middleware for Express.\n *\n * @param apiUrl Api URL to forward requests to\n * @returns Proxy middleware function\n */\nexport const forwardingProxy =\n\t(apiUrl: string) =>\n\t(\n\t\tmethod: ForwardingProxyType[\"method\"],\n\t\tforwardPath: ForwardingProxyType[\"forwardPath\"],\n\t\tproxyReqOptDecorator?: ForwardingProxyType[\"proxyReqOptDecorator\"],\n\t) =>\n\t\tproxy(\n\t\t\tapiUrl,\n\t\t\tproxyConfig(\n\t\t\t\tmethod,\n\t\t\t\t(...params) =>\n\t\t\t\t\tstripTrailingSlash(new URL(apiUrl).pathname) + forwardPath(...params),\n\t\t\t\tproxyReqOptDecorator,\n\t\t\t),\n\t\t);\n"],"mappings":"8kBAGA,IAAM,EAAgB,GACrB,iCAAiC,KAAK,EAAI,QAAQ,eAAiB,GAAG,CAE1D,GACZ,EACA,EACA,IACiC,CACjC,IAAM,EAAc,MAAM,QAAQ,EAAQ,CAAG,EAAU,CAAC,EAAQ,CAEhE,MAAO,CACN,OAAS,GACR,EAAY,SAAS,EAAI,OAAO,EAAI,EAAa,EAAI,CACtD,uBACA,uBACA,uBAAwB,EAAa,IAAY,EACjD,MAAO,GAAG,QAAQ,IAAI,iBAAmB,IAAI,IAC7C,EAGI,EAAsB,GAC3B,EAAI,SAAS,IAAI,CAAG,EAAI,UAAU,EAAG,EAAI,OAAS,EAAE,CAAG,EAc3C,EACX,IAEA,EACA,EACA,KAAA,EAAA,EAAA,SAGC,EACA,EACC,GACC,GAAG,IACH,EAAmB,IAAI,IAAI,EAAO,CAAC,SAAS,CAAG,EAAY,GAAG,EAAO,CACtE,EACA,CACD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import e from "express-http-proxy";
|
|
2
|
+
//#region src/forwardingproxy.ts
|
|
3
|
+
var t = (e) => /(^undefined$)|(^Bearer .+$)/gim.test(e.headers.authorization || ""), n = (e, n, r) => {
|
|
4
|
+
let i = Array.isArray(e) ? e : [e];
|
|
5
|
+
return {
|
|
6
|
+
filter: (e) => i.includes(e.method) && t(e),
|
|
7
|
+
proxyReqPathResolver: n,
|
|
8
|
+
proxyReqOptDecorator: r,
|
|
9
|
+
proxyReqBodyDecorator: (e, t) => e,
|
|
10
|
+
limit: `${process.env.UPLOAD_LIMIT_MB || 200}mb`
|
|
11
|
+
};
|
|
12
|
+
}, r = (e) => e.endsWith("/") ? e.substring(0, e.length - 1) : e, i = (t) => (i, a, o) => e(t, n(i, (...e) => r(new URL(t).pathname) + a(...e), o));
|
|
13
|
+
//#endregion
|
|
14
|
+
export { i as forwardingProxy, n as proxyConfig };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/forwardingproxy.ts"],"sourcesContent":["import type { Request } from \"express\";\nimport proxy, { type ProxyOptions } from \"express-http-proxy\";\n\nconst requireOAuth = (req: Request) =>\n\t/(^undefined$)|(^Bearer .+$)/gim.test(req.headers.authorization || \"\");\n\nexport const proxyConfig = (\n\tmethods: string[],\n\tproxyReqPathResolver: Required<ProxyOptions>[\"proxyReqPathResolver\"],\n\tproxyReqOptDecorator?: Required<ProxyOptions>[\"proxyReqOptDecorator\"],\n): Parameters<typeof proxy>[1] => {\n\tconst httpMethods = Array.isArray(methods) ? methods : [methods];\n\n\treturn {\n\t\tfilter: (req: Request) =>\n\t\t\thttpMethods.includes(req.method) && requireOAuth(req),\n\t\tproxyReqPathResolver,\n\t\tproxyReqOptDecorator,\n\t\tproxyReqBodyDecorator: (bodyContent, _srcReq) => bodyContent,\n\t\tlimit: `${process.env.UPLOAD_LIMIT_MB || 200}mb`,\n\t};\n};\n\nconst stripTrailingSlash = (url: string) =>\n\turl.endsWith(\"/\") ? url.substring(0, url.length - 1) : url;\n\nexport type ForwardingProxyType = {\n\tmethod: string[];\n\tforwardPath: (...reqs: Request[]) => string;\n\tproxyReqOptDecorator?: Required<ProxyOptions>[\"proxyReqOptDecorator\"];\n};\n\n/**\n * Creates a forwarding proxy middleware for Express.\n *\n * @param apiUrl Api URL to forward requests to\n * @returns Proxy middleware function\n */\nexport const forwardingProxy =\n\t(apiUrl: string) =>\n\t(\n\t\tmethod: ForwardingProxyType[\"method\"],\n\t\tforwardPath: ForwardingProxyType[\"forwardPath\"],\n\t\tproxyReqOptDecorator?: ForwardingProxyType[\"proxyReqOptDecorator\"],\n\t) =>\n\t\tproxy(\n\t\t\tapiUrl,\n\t\t\tproxyConfig(\n\t\t\t\tmethod,\n\t\t\t\t(...params) =>\n\t\t\t\t\tstripTrailingSlash(new URL(apiUrl).pathname) + forwardPath(...params),\n\t\t\t\tproxyReqOptDecorator,\n\t\t\t),\n\t\t);\n"],"mappings":";;AAGA,IAAM,KAAgB,MACrB,iCAAiC,KAAK,EAAI,QAAQ,iBAAiB,GAAG,EAE1D,KACZ,GACA,GACA,MACiC;CACjC,IAAM,IAAc,MAAM,QAAQ,EAAQ,GAAG,IAAU,CAAC,EAAQ;AAEhE,QAAO;EACN,SAAS,MACR,EAAY,SAAS,EAAI,OAAO,IAAI,EAAa,EAAI;EACtD;EACA;EACA,wBAAwB,GAAa,MAAY;EACjD,OAAO,GAAG,QAAQ,IAAI,mBAAmB,IAAI;EAC7C;GAGI,KAAsB,MAC3B,EAAI,SAAS,IAAI,GAAG,EAAI,UAAU,GAAG,EAAI,SAAS,EAAE,GAAG,GAc3C,KACX,OAEA,GACA,GACA,MAEA,EACC,GACA,EACC,IACC,GAAG,MACH,EAAmB,IAAI,IAAI,EAAO,CAAC,SAAS,GAAG,EAAY,GAAG,EAAO,EACtE,EACA,CACD"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entur-partner/bff",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-alpha.0",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"default": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
8
15
|
"files": [
|
|
9
16
|
"dist"
|
|
10
17
|
],
|
|
@@ -17,27 +24,15 @@
|
|
|
17
24
|
"access": "public"
|
|
18
25
|
},
|
|
19
26
|
"scripts": {
|
|
20
|
-
"
|
|
21
|
-
"build": "dts build",
|
|
22
|
-
"test": "dts test --env=jsdom --passWithNoTests",
|
|
23
|
-
"lint": "dts lint"
|
|
27
|
+
"build": "vite build && tsc -p tsconfig.build.json"
|
|
24
28
|
},
|
|
25
29
|
"dependencies": {
|
|
26
30
|
"express-http-proxy": "^2.1.2"
|
|
27
31
|
},
|
|
28
32
|
"devDependencies": {
|
|
29
|
-
"@types/express-http-proxy": "1.6.7"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"globalSetup": "../../global-jest-setup.js",
|
|
33
|
-
"collectCoverageFrom": [
|
|
34
|
-
"<rootDir>/src/**/*.{js,jsx,ts,tsx}"
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
|
-
"jestSonar": {
|
|
38
|
-
"reportPath": "reports/jest/",
|
|
39
|
-
"reportFile": "jest-sonar-report.xml",
|
|
40
|
-
"indent": 4
|
|
33
|
+
"@types/express-http-proxy": "1.6.7",
|
|
34
|
+
"typescript": "6.0.2",
|
|
35
|
+
"vite": "8.0.8"
|
|
41
36
|
},
|
|
42
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "80555bc6012ccbf5221cea5e1199b4b72bd090ae"
|
|
43
38
|
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var proxy = require('express-http-proxy');
|
|
6
|
-
|
|
7
|
-
var requireOAuth = function requireOAuth(req) {
|
|
8
|
-
return /(^undefined$)|(^Bearer .+$)/gim.test(req.headers.authorization || "");
|
|
9
|
-
};
|
|
10
|
-
var proxyConfig = function proxyConfig(methods, proxyReqPathResolver, proxyReqOptDecorator) {
|
|
11
|
-
var httpMethods = Array.isArray(methods) ? methods : [methods];
|
|
12
|
-
return {
|
|
13
|
-
filter: function filter(req) {
|
|
14
|
-
return httpMethods.includes(req.method) && requireOAuth(req);
|
|
15
|
-
},
|
|
16
|
-
proxyReqPathResolver: proxyReqPathResolver,
|
|
17
|
-
proxyReqOptDecorator: proxyReqOptDecorator,
|
|
18
|
-
proxyReqBodyDecorator: function proxyReqBodyDecorator(bodyContent, _srcReq) {
|
|
19
|
-
return bodyContent;
|
|
20
|
-
},
|
|
21
|
-
limit: (process.env.UPLOAD_LIMIT_MB || 200) + "mb"
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
var stripTrailingSlash = function stripTrailingSlash(url) {
|
|
25
|
-
return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Creates a forwarding proxy middleware for Express.
|
|
29
|
-
*
|
|
30
|
-
* @param apiUrl Api URL to forward requests to
|
|
31
|
-
* @returns Proxy middleware function
|
|
32
|
-
*/
|
|
33
|
-
var forwardingProxy = function forwardingProxy(apiUrl) {
|
|
34
|
-
return function (method, forwardPath, proxyReqOptDecorator) {
|
|
35
|
-
return proxy(apiUrl, proxyConfig(method, function () {
|
|
36
|
-
return stripTrailingSlash(new URL(apiUrl).pathname) + forwardPath.apply(void 0, arguments);
|
|
37
|
-
}, proxyReqOptDecorator));
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
exports.forwardingProxy = forwardingProxy;
|
|
42
|
-
exports.proxyConfig = proxyConfig;
|
|
43
|
-
//# sourceMappingURL=bff.cjs.development.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bff.cjs.development.js","sources":["../src/forwardingproxy.ts"],"sourcesContent":["import type { Request } from \"express\";\nimport proxy, { type ProxyOptions } from \"express-http-proxy\";\n\nconst requireOAuth = (req: Request) =>\n\t/(^undefined$)|(^Bearer .+$)/gim.test(req.headers.authorization || \"\");\n\nexport const proxyConfig = (\n\tmethods: string[],\n\tproxyReqPathResolver: Required<ProxyOptions>[\"proxyReqPathResolver\"],\n\tproxyReqOptDecorator?: Required<ProxyOptions>[\"proxyReqOptDecorator\"],\n): Parameters<typeof proxy>[1] => {\n\tconst httpMethods = Array.isArray(methods) ? methods : [methods];\n\n\treturn {\n\t\tfilter: (req: Request) =>\n\t\t\thttpMethods.includes(req.method) && requireOAuth(req),\n\t\tproxyReqPathResolver,\n\t\tproxyReqOptDecorator,\n\t\tproxyReqBodyDecorator: (bodyContent, _srcReq) => bodyContent,\n\t\tlimit: `${process.env.UPLOAD_LIMIT_MB || 200}mb`,\n\t};\n};\n\nconst stripTrailingSlash = (url: string) =>\n\turl.endsWith(\"/\") ? url.substring(0, url.length - 1) : url;\n\nexport type ForwardingProxyType = {\n\tmethod: string[];\n\tforwardPath: (...reqs: Request[]) => string;\n\tproxyReqOptDecorator?: Required<ProxyOptions>[\"proxyReqOptDecorator\"];\n};\n\n/**\n * Creates a forwarding proxy middleware for Express.\n *\n * @param apiUrl Api URL to forward requests to\n * @returns Proxy middleware function\n */\nexport const forwardingProxy =\n\t(apiUrl: string) =>\n\t(\n\t\tmethod: ForwardingProxyType[\"method\"],\n\t\tforwardPath: ForwardingProxyType[\"forwardPath\"],\n\t\tproxyReqOptDecorator?: ForwardingProxyType[\"proxyReqOptDecorator\"],\n\t) =>\n\t\tproxy(\n\t\t\tapiUrl,\n\t\t\tproxyConfig(\n\t\t\t\tmethod,\n\t\t\t\t(...params) =>\n\t\t\t\t\tstripTrailingSlash(new URL(apiUrl).pathname) + forwardPath(...params),\n\t\t\t\tproxyReqOptDecorator,\n\t\t\t),\n\t\t);\n"],"names":["requireOAuth","req","test","headers","authorization","proxyConfig","methods","proxyReqPathResolver","proxyReqOptDecorator","httpMethods","Array","isArray","filter","includes","method","proxyReqBodyDecorator","bodyContent","_srcReq","limit","process","env","UPLOAD_LIMIT_MB","stripTrailingSlash","url","endsWith","substring","length","forwardingProxy","apiUrl","forwardPath","proxy","URL","pathname","apply","arguments"],"mappings":";;;;;;AAGA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,CAAIC,GAAY,EAAA;EAAA,OACjC,gCAAgC,CAACC,IAAI,CAACD,GAAG,CAACE,OAAO,CAACC,aAAa,IAAI,EAAE,CAAC,CAAA;AAAA,CAAA,CAAA;AAEhE,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CACvBC,OAAiB,EACjBC,oBAAoE,EACpEC,oBAAqE,EACrC;AAChC,EAAA,IAAMC,WAAW,GAAGC,KAAK,CAACC,OAAO,CAACL,OAAO,CAAC,GAAGA,OAAO,GAAG,CAACA,OAAO,CAAC,CAAA;EAEhE,OAAO;AACNM,IAAAA,MAAM,EAAE,SAARA,MAAMA,CAAGX,GAAY,EAAA;AAAA,MAAA,OACpBQ,WAAW,CAACI,QAAQ,CAACZ,GAAG,CAACa,MAAM,CAAC,IAAId,YAAY,CAACC,GAAG,CAAC,CAAA;AAAA,KAAA;AACtDM,IAAAA,oBAAoB,EAApBA,oBAAoB;AACpBC,IAAAA,oBAAoB,EAApBA,oBAAoB;AACpBO,IAAAA,qBAAqB,EAAE,SAAvBA,qBAAqBA,CAAGC,WAAW,EAAEC,OAAO,EAAA;AAAA,MAAA,OAAKD,WAAW,CAAA;AAAA,KAAA;AAC5DE,IAAAA,KAAK,GAAKC,OAAO,CAACC,GAAG,CAACC,eAAe,IAAI,GAAG,IAAA,IAAA;GAC5C,CAAA;AACF,EAAC;AAED,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAIC,GAAW,EAAA;EAAA,OACtCA,GAAG,CAACC,QAAQ,CAAC,GAAG,CAAC,GAAGD,GAAG,CAACE,SAAS,CAAC,CAAC,EAAEF,GAAG,CAACG,MAAM,GAAG,CAAC,CAAC,GAAGH,GAAG,CAAA;AAAA,CAAA,CAAA;AAQ3D;;;;;AAKG;IACUI,eAAe,GAC3B,SADYA,eAAeA,CAC1BC,MAAc,EAAA;AAAA,EAAA,OACf,UACCd,MAAqC,EACrCe,WAA+C,EAC/CrB,oBAAkE,EAAA;AAAA,IAAA,OAElEsB,KAAK,CACJF,MAAM,EACNvB,WAAW,CACVS,MAAM,EACN,YAAA;AAAA,MAAA,OACCQ,kBAAkB,CAAC,IAAIS,GAAG,CAACH,MAAM,CAAC,CAACI,QAAQ,CAAC,GAAGH,WAAW,CAAAI,KAAA,CAAA,KAAA,CAAA,EAAAC,SAAU,CAAC,CAAA;KACtE1B,EAAAA,oBAAoB,CACpB,CACD,CAAA;AAAA,GAAA,CAAA;AAAA;;;;;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("express-http-proxy"),e=function(r,e,t){var n=Array.isArray(r)?r:[r];return{filter:function(r){return n.includes(r.method)&&function(r){return/(^undefined$)|(^Bearer .+$)/gim.test(r.headers.authorization||"")}(r)},proxyReqPathResolver:e,proxyReqOptDecorator:t,proxyReqBodyDecorator:function(r,e){return r},limit:(process.env.UPLOAD_LIMIT_MB||200)+"mb"}};exports.forwardingProxy=function(t){return function(n,o,i){return r(t,e(n,function(){return((r=new URL(t).pathname).endsWith("/")?r.substring(0,r.length-1):r)+o.apply(void 0,arguments);var r},i))}},exports.proxyConfig=e;
|
|
2
|
-
//# sourceMappingURL=bff.cjs.production.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bff.cjs.production.min.js","sources":["../src/forwardingproxy.ts"],"sourcesContent":["import type { Request } from \"express\";\nimport proxy, { type ProxyOptions } from \"express-http-proxy\";\n\nconst requireOAuth = (req: Request) =>\n\t/(^undefined$)|(^Bearer .+$)/gim.test(req.headers.authorization || \"\");\n\nexport const proxyConfig = (\n\tmethods: string[],\n\tproxyReqPathResolver: Required<ProxyOptions>[\"proxyReqPathResolver\"],\n\tproxyReqOptDecorator?: Required<ProxyOptions>[\"proxyReqOptDecorator\"],\n): Parameters<typeof proxy>[1] => {\n\tconst httpMethods = Array.isArray(methods) ? methods : [methods];\n\n\treturn {\n\t\tfilter: (req: Request) =>\n\t\t\thttpMethods.includes(req.method) && requireOAuth(req),\n\t\tproxyReqPathResolver,\n\t\tproxyReqOptDecorator,\n\t\tproxyReqBodyDecorator: (bodyContent, _srcReq) => bodyContent,\n\t\tlimit: `${process.env.UPLOAD_LIMIT_MB || 200}mb`,\n\t};\n};\n\nconst stripTrailingSlash = (url: string) =>\n\turl.endsWith(\"/\") ? url.substring(0, url.length - 1) : url;\n\nexport type ForwardingProxyType = {\n\tmethod: string[];\n\tforwardPath: (...reqs: Request[]) => string;\n\tproxyReqOptDecorator?: Required<ProxyOptions>[\"proxyReqOptDecorator\"];\n};\n\n/**\n * Creates a forwarding proxy middleware for Express.\n *\n * @param apiUrl Api URL to forward requests to\n * @returns Proxy middleware function\n */\nexport const forwardingProxy =\n\t(apiUrl: string) =>\n\t(\n\t\tmethod: ForwardingProxyType[\"method\"],\n\t\tforwardPath: ForwardingProxyType[\"forwardPath\"],\n\t\tproxyReqOptDecorator?: ForwardingProxyType[\"proxyReqOptDecorator\"],\n\t) =>\n\t\tproxy(\n\t\t\tapiUrl,\n\t\t\tproxyConfig(\n\t\t\t\tmethod,\n\t\t\t\t(...params) =>\n\t\t\t\t\tstripTrailingSlash(new URL(apiUrl).pathname) + forwardPath(...params),\n\t\t\t\tproxyReqOptDecorator,\n\t\t\t),\n\t\t);\n"],"names":["proxyConfig","methods","proxyReqPathResolver","proxyReqOptDecorator","httpMethods","Array","isArray","filter","req","includes","method","test","headers","authorization","requireOAuth","proxyReqBodyDecorator","bodyContent","_srcReq","limit","process","env","UPLOAD_LIMIT_MB","apiUrl","forwardPath","proxy","url","URL","pathname","endsWith","substring","length","apply","arguments"],"mappings":"wGAMaA,EAAc,SAC1BC,EACAC,EACAC,GAEA,IAAMC,EAAcC,MAAMC,QAAQL,GAAWA,EAAU,CAACA,GAExD,MAAO,CACNM,OAAQ,SAACC,GAAY,OACpBJ,EAAYK,SAASD,EAAIE,SAZP,SAACF,GAAY,MACjC,iCAAiCG,KAAKH,EAAII,QAAQC,eAAiB,GAAG,CAWhCC,CAAaN,EAAI,EACtDN,qBAAAA,EACAC,qBAAAA,EACAY,sBAAuB,SAACC,EAAaC,GAAO,OAAKD,CAAW,EAC5DE,OAAUC,QAAQC,IAAIC,iBAAmB,KAAG,KAE9C,0BAkBC,SAACC,GAAc,OACf,SACCZ,EACAa,EACApB,GAAkE,OAElEqB,EACCF,EACAtB,EACCU,EACA,WAAA,QA1BwBe,EA2BJ,IAAIC,IAAIJ,GAAQK,UA1BnCC,SAAS,KAAOH,EAAII,UAAU,EAAGJ,EAAIK,OAAS,GAAKL,GA0BJF,EAAWQ,WAAA,EAAAC,WA3BpC,IAACP,GA4BxBtB,GAED,CAAA"}
|
package/dist/bff.esm.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import proxy from 'express-http-proxy';
|
|
2
|
-
|
|
3
|
-
var requireOAuth = function requireOAuth(req) {
|
|
4
|
-
return /(^undefined$)|(^Bearer .+$)/gim.test(req.headers.authorization || "");
|
|
5
|
-
};
|
|
6
|
-
var proxyConfig = function proxyConfig(methods, proxyReqPathResolver, proxyReqOptDecorator) {
|
|
7
|
-
var httpMethods = Array.isArray(methods) ? methods : [methods];
|
|
8
|
-
return {
|
|
9
|
-
filter: function filter(req) {
|
|
10
|
-
return httpMethods.includes(req.method) && requireOAuth(req);
|
|
11
|
-
},
|
|
12
|
-
proxyReqPathResolver: proxyReqPathResolver,
|
|
13
|
-
proxyReqOptDecorator: proxyReqOptDecorator,
|
|
14
|
-
proxyReqBodyDecorator: function proxyReqBodyDecorator(bodyContent, _srcReq) {
|
|
15
|
-
return bodyContent;
|
|
16
|
-
},
|
|
17
|
-
limit: (process.env.UPLOAD_LIMIT_MB || 200) + "mb"
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
var stripTrailingSlash = function stripTrailingSlash(url) {
|
|
21
|
-
return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Creates a forwarding proxy middleware for Express.
|
|
25
|
-
*
|
|
26
|
-
* @param apiUrl Api URL to forward requests to
|
|
27
|
-
* @returns Proxy middleware function
|
|
28
|
-
*/
|
|
29
|
-
var forwardingProxy = function forwardingProxy(apiUrl) {
|
|
30
|
-
return function (method, forwardPath, proxyReqOptDecorator) {
|
|
31
|
-
return proxy(apiUrl, proxyConfig(method, function () {
|
|
32
|
-
return stripTrailingSlash(new URL(apiUrl).pathname) + forwardPath.apply(void 0, arguments);
|
|
33
|
-
}, proxyReqOptDecorator));
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export { forwardingProxy, proxyConfig };
|
|
38
|
-
//# sourceMappingURL=bff.esm.js.map
|
package/dist/bff.esm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bff.esm.js","sources":["../src/forwardingproxy.ts"],"sourcesContent":["import type { Request } from \"express\";\nimport proxy, { type ProxyOptions } from \"express-http-proxy\";\n\nconst requireOAuth = (req: Request) =>\n\t/(^undefined$)|(^Bearer .+$)/gim.test(req.headers.authorization || \"\");\n\nexport const proxyConfig = (\n\tmethods: string[],\n\tproxyReqPathResolver: Required<ProxyOptions>[\"proxyReqPathResolver\"],\n\tproxyReqOptDecorator?: Required<ProxyOptions>[\"proxyReqOptDecorator\"],\n): Parameters<typeof proxy>[1] => {\n\tconst httpMethods = Array.isArray(methods) ? methods : [methods];\n\n\treturn {\n\t\tfilter: (req: Request) =>\n\t\t\thttpMethods.includes(req.method) && requireOAuth(req),\n\t\tproxyReqPathResolver,\n\t\tproxyReqOptDecorator,\n\t\tproxyReqBodyDecorator: (bodyContent, _srcReq) => bodyContent,\n\t\tlimit: `${process.env.UPLOAD_LIMIT_MB || 200}mb`,\n\t};\n};\n\nconst stripTrailingSlash = (url: string) =>\n\turl.endsWith(\"/\") ? url.substring(0, url.length - 1) : url;\n\nexport type ForwardingProxyType = {\n\tmethod: string[];\n\tforwardPath: (...reqs: Request[]) => string;\n\tproxyReqOptDecorator?: Required<ProxyOptions>[\"proxyReqOptDecorator\"];\n};\n\n/**\n * Creates a forwarding proxy middleware for Express.\n *\n * @param apiUrl Api URL to forward requests to\n * @returns Proxy middleware function\n */\nexport const forwardingProxy =\n\t(apiUrl: string) =>\n\t(\n\t\tmethod: ForwardingProxyType[\"method\"],\n\t\tforwardPath: ForwardingProxyType[\"forwardPath\"],\n\t\tproxyReqOptDecorator?: ForwardingProxyType[\"proxyReqOptDecorator\"],\n\t) =>\n\t\tproxy(\n\t\t\tapiUrl,\n\t\t\tproxyConfig(\n\t\t\t\tmethod,\n\t\t\t\t(...params) =>\n\t\t\t\t\tstripTrailingSlash(new URL(apiUrl).pathname) + forwardPath(...params),\n\t\t\t\tproxyReqOptDecorator,\n\t\t\t),\n\t\t);\n"],"names":["requireOAuth","req","test","headers","authorization","proxyConfig","methods","proxyReqPathResolver","proxyReqOptDecorator","httpMethods","Array","isArray","filter","includes","method","proxyReqBodyDecorator","bodyContent","_srcReq","limit","process","env","UPLOAD_LIMIT_MB","stripTrailingSlash","url","endsWith","substring","length","forwardingProxy","apiUrl","forwardPath","proxy","URL","pathname","apply","arguments"],"mappings":";;AAGA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,CAAIC,GAAY,EAAA;EAAA,OACjC,gCAAgC,CAACC,IAAI,CAACD,GAAG,CAACE,OAAO,CAACC,aAAa,IAAI,EAAE,CAAC,CAAA;AAAA,CAAA,CAAA;AAEhE,IAAMC,WAAW,GAAG,SAAdA,WAAWA,CACvBC,OAAiB,EACjBC,oBAAoE,EACpEC,oBAAqE,EACrC;AAChC,EAAA,IAAMC,WAAW,GAAGC,KAAK,CAACC,OAAO,CAACL,OAAO,CAAC,GAAGA,OAAO,GAAG,CAACA,OAAO,CAAC,CAAA;EAEhE,OAAO;AACNM,IAAAA,MAAM,EAAE,SAARA,MAAMA,CAAGX,GAAY,EAAA;AAAA,MAAA,OACpBQ,WAAW,CAACI,QAAQ,CAACZ,GAAG,CAACa,MAAM,CAAC,IAAId,YAAY,CAACC,GAAG,CAAC,CAAA;AAAA,KAAA;AACtDM,IAAAA,oBAAoB,EAApBA,oBAAoB;AACpBC,IAAAA,oBAAoB,EAApBA,oBAAoB;AACpBO,IAAAA,qBAAqB,EAAE,SAAvBA,qBAAqBA,CAAGC,WAAW,EAAEC,OAAO,EAAA;AAAA,MAAA,OAAKD,WAAW,CAAA;AAAA,KAAA;AAC5DE,IAAAA,KAAK,GAAKC,OAAO,CAACC,GAAG,CAACC,eAAe,IAAI,GAAG,IAAA,IAAA;GAC5C,CAAA;AACF,EAAC;AAED,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAIC,GAAW,EAAA;EAAA,OACtCA,GAAG,CAACC,QAAQ,CAAC,GAAG,CAAC,GAAGD,GAAG,CAACE,SAAS,CAAC,CAAC,EAAEF,GAAG,CAACG,MAAM,GAAG,CAAC,CAAC,GAAGH,GAAG,CAAA;AAAA,CAAA,CAAA;AAQ3D;;;;;AAKG;IACUI,eAAe,GAC3B,SADYA,eAAeA,CAC1BC,MAAc,EAAA;AAAA,EAAA,OACf,UACCd,MAAqC,EACrCe,WAA+C,EAC/CrB,oBAAkE,EAAA;AAAA,IAAA,OAElEsB,KAAK,CACJF,MAAM,EACNvB,WAAW,CACVS,MAAM,EACN,YAAA;AAAA,MAAA,OACCQ,kBAAkB,CAAC,IAAIS,GAAG,CAACH,MAAM,CAAC,CAACI,QAAQ,CAAC,GAAGH,WAAW,CAAAI,KAAA,CAAA,KAAA,CAAA,EAAAC,SAAU,CAAC,CAAA;KACtE1B,EAAAA,oBAAoB,CACpB,CACD,CAAA;AAAA,GAAA,CAAA;AAAA;;;;"}
|