@entur-partner/bff 1.2.8-alpha.0 → 1.2.9

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.
@@ -24,12 +24,14 @@ var proxyConfig = function proxyConfig(methods, proxyReqPathResolver, proxyReqOp
24
24
  var stripTrailingSlash = function stripTrailingSlash(url) {
25
25
  return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
26
26
  };
27
- console.log("WHATAFUCK?");
28
- // forwards a call of a specific url / set of methods to a remote server
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
+ */
29
33
  var forwardingProxy = function forwardingProxy(apiUrl) {
30
34
  return function (method, forwardPath, proxyReqOptDecorator) {
31
- var methodsForLog = Array.isArray(method) ? method.join(", ") : method;
32
- console.log("Setting up forwarding proxy to " + apiUrl + " for methods: " + methodsForLog);
33
35
  return proxy(apiUrl, proxyConfig(method, function () {
34
36
  return stripTrailingSlash(new URL(apiUrl).pathname) + forwardPath.apply(void 0, arguments);
35
37
  }, proxyReqOptDecorator));
@@ -1 +1 @@
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};\nconsole.log(\"WHATAFUCK?\");\n// forwards a call of a specific url / set of methods to a remote server\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\tconst methodsForLog = Array.isArray(method) ? method.join(\", \") : method;\n\t\tconsole.log(\n\t\t\t`Setting up forwarding proxy to ${apiUrl} for methods: ${methodsForLog}`,\n\t\t);\n\t\treturn proxy(\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\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","console","log","forwardingProxy","apiUrl","forwardPath","methodsForLog","join","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,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,CAAC,GAAGnB,MAAM,CAAA;AACxEa,IAAAA,OAAO,CAACC,GAAG,CAAA,iCAAA,GACwBE,MAAM,GAAA,gBAAA,GAAiBE,aAAe,CACxE,CAAA;AACD,IAAA,OAAOE,KAAK,CACXJ,MAAM,EACNzB,WAAW,CACVS,MAAM,EACN,YAAA;AAAA,MAAA,OACCQ,kBAAkB,CAAC,IAAIa,GAAG,CAACL,MAAM,CAAC,CAACM,QAAQ,CAAC,GAAGL,WAAW,CAAAM,KAAA,CAAA,KAAA,CAAA,EAAAC,SAAU,CAAC,CAAA;KACtE9B,EAAAA,oBAAoB,CACpB,CACD,CAAA;GACD,CAAA;AAAA;;;;;"}
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 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("express-http-proxy"),e=function(r,e,o){var t=Array.isArray(r)?r:[r];return{filter:function(r){return t.includes(r.method)&&function(r){return/(^undefined$)|(^Bearer .+$)/gim.test(r.headers.authorization||"")}(r)},proxyReqPathResolver:e,proxyReqOptDecorator:o,proxyReqBodyDecorator:function(r,e){return r},limit:(process.env.UPLOAD_LIMIT_MB||200)+"mb"}};console.log("WHATAFUCK?"),exports.forwardingProxy=function(o){return function(t,n,i){var u=Array.isArray(t)?t.join(", "):t;return console.log("Setting up forwarding proxy to "+o+" for methods: "+u),r(o,e(t,function(){return((r=new URL(o).pathname).endsWith("/")?r.substring(0,r.length-1):r)+n.apply(void 0,arguments);var r},i))}},exports.proxyConfig=e;
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
2
  //# sourceMappingURL=bff.cjs.production.min.js.map
@@ -1 +1 @@
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};\nconsole.log(\"WHATAFUCK?\");\n// forwards a call of a specific url / set of methods to a remote server\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\tconst methodsForLog = Array.isArray(method) ? method.join(\", \") : method;\n\t\tconsole.log(\n\t\t\t`Setting up forwarding proxy to ${apiUrl} for methods: ${methodsForLog}`,\n\t\t);\n\t\treturn proxy(\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\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","console","log","apiUrl","forwardPath","methodsForLog","join","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,EAUAC,QAAQC,IAAI,sCAGX,SAACC,GAAc,OACf,SACCd,EACAe,EACAtB,GAEA,IAAMuB,EAAgBrB,MAAMC,QAAQI,GAAUA,EAAOiB,KAAK,MAAQjB,EAIlE,OAHAY,QAAQC,IAAG,kCACwBC,EAAM,iBAAiBE,GAEnDE,EACNJ,EACAxB,EACCU,EACA,WAAA,QAzBwBmB,EA0BJ,IAAIC,IAAIN,GAAQO,UAzBnCC,SAAS,KAAOH,EAAII,UAAU,EAAGJ,EAAIK,OAAS,GAAKL,GAyBJJ,EAAWU,WAAA,EAAAC,WA1BpC,IAACP,GA2BxB1B,IAGF"}
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 CHANGED
@@ -20,12 +20,14 @@ var proxyConfig = function proxyConfig(methods, proxyReqPathResolver, proxyReqOp
20
20
  var stripTrailingSlash = function stripTrailingSlash(url) {
21
21
  return url.endsWith("/") ? url.substring(0, url.length - 1) : url;
22
22
  };
23
- console.log("WHATAFUCK?");
24
- // forwards a call of a specific url / set of methods to a remote server
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
+ */
25
29
  var forwardingProxy = function forwardingProxy(apiUrl) {
26
30
  return function (method, forwardPath, proxyReqOptDecorator) {
27
- var methodsForLog = Array.isArray(method) ? method.join(", ") : method;
28
- console.log("Setting up forwarding proxy to " + apiUrl + " for methods: " + methodsForLog);
29
31
  return proxy(apiUrl, proxyConfig(method, function () {
30
32
  return stripTrailingSlash(new URL(apiUrl).pathname) + forwardPath.apply(void 0, arguments);
31
33
  }, proxyReqOptDecorator));
@@ -1 +1 @@
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};\nconsole.log(\"WHATAFUCK?\");\n// forwards a call of a specific url / set of methods to a remote server\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\tconst methodsForLog = Array.isArray(method) ? method.join(\", \") : method;\n\t\tconsole.log(\n\t\t\t`Setting up forwarding proxy to ${apiUrl} for methods: ${methodsForLog}`,\n\t\t);\n\t\treturn proxy(\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\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","console","log","forwardingProxy","apiUrl","forwardPath","methodsForLog","join","proxy","URL","pathname","apply","arguments"],"mappings":";;AAGA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,CAAIC,GAAY,EAAA;EAAA,OACjC,gCAAgC,CAACC,IAAI,CAACD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OAAO,CAACG,MAAM,CAAC,GAAGA,MAAM,CAACmB,IAAI,CAAC,IAAI,CAAC,GAAGnB,MAAM,CAAA;AACxEa,IAAAA,OAAO,CAACC,GAAG,CAAA,iCAAA,GACwBE,MAAM,GAAA,gBAAA,GAAiBE,aAAe,CACxE,CAAA;AACD,IAAA,OAAOE,KAAK,CACXJ,MAAM,EACNzB,WAAW,CACVS,MAAM,EACN,YAAA;AAAA,MAAA,OACCQ,kBAAkB,CAAC,IAAIa,GAAG,CAACL,MAAM,CAAC,CAACM,QAAQ,CAAC,GAAGL,WAAW,CAAAM,KAAA,CAAA,KAAA,CAAA,EAAAC,SAAU,CAAC,CAAA;KACtE9B,EAAAA,oBAAoB,CACpB,CACD,CAAA;GACD,CAAA;AAAA;;;;"}
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;;;;"}
@@ -6,4 +6,10 @@ export type ForwardingProxyType = {
6
6
  forwardPath: (...reqs: Request[]) => string;
7
7
  proxyReqOptDecorator?: Required<ProxyOptions>["proxyReqOptDecorator"];
8
8
  };
9
+ /**
10
+ * Creates a forwarding proxy middleware for Express.
11
+ *
12
+ * @param apiUrl Api URL to forward requests to
13
+ * @returns Proxy middleware function
14
+ */
9
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>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entur-partner/bff",
3
- "version": "1.2.8-alpha.0",
3
+ "version": "1.2.9",
4
4
  "license": "EUPL-1.2",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/bff.esm.js",
@@ -23,10 +23,10 @@
23
23
  "lint": "dts lint"
24
24
  },
25
25
  "dependencies": {
26
- "express-http-proxy": "^1.6.3"
26
+ "express-http-proxy": "^2.1.2"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/express-http-proxy": "1.6.6"
29
+ "@types/express-http-proxy": "1.6.7"
30
30
  },
31
31
  "jest": {
32
32
  "globalSetup": "../../global-jest-setup.js",
@@ -39,5 +39,5 @@
39
39
  "reportFile": "jest-sonar-report.xml",
40
40
  "indent": 4
41
41
  },
42
- "gitHead": "1822e8405da7670f164d6cd5d6e87a3cca01ba13"
42
+ "gitHead": "b167f46c19c7ae5949e8df86b375eb56067dbbc8"
43
43
  }