@sap-ux/ui5-proxy-middleware 1.4.20 → 1.4.21

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.
@@ -1,7 +1,7 @@
1
1
  import type { ClientRequest, IncomingMessage, ServerResponse } from 'http';
2
2
  import type { ToolsLogger } from '@sap-ux/logger';
3
3
  import { type Manifest } from '@sap-ux/project-access';
4
- import type { NextFunction, Request, Response } from 'express';
4
+ import type { RequestHandler, NextFunction, Request, Response } from 'express';
5
5
  import type { ProxyConfig } from './types';
6
6
  import type { Url } from 'url';
7
7
  import type { ReaderCollection } from '@ui5/fs';
@@ -124,4 +124,13 @@ export declare function proxyErrorHandler(err: Error & {
124
124
  next?: Function;
125
125
  originalUrl?: string;
126
126
  }, logger: ToolsLogger, _res?: ServerResponse, _target?: string | Partial<Url>): void;
127
+ /**
128
+ * Adjust UI5 bootstrap URLs to load directly from UI5 CDN.
129
+ *
130
+ * @param ui5Configs the UI5 configuration of the ui5-proxy-middleware
131
+ * @param rootProject the project root
132
+ * @param logger logger to be used when running the middleware
133
+ * @returns RequestHandler to adjust bootstraps
134
+ */
135
+ export declare function directLoadProxy(ui5Configs: ProxyConfig[], rootProject: ReaderCollection, logger: ToolsLogger): RequestHandler;
127
136
  //# sourceMappingURL=utils.d.ts.map
@@ -5,6 +5,7 @@ exports.updateProxyEnv = updateProxyEnv;
5
5
  exports.resolveUI5Version = resolveUI5Version;
6
6
  exports.injectUI5Url = injectUI5Url;
7
7
  exports.proxyErrorHandler = proxyErrorHandler;
8
+ exports.directLoadProxy = directLoadProxy;
8
9
  const project_access_1 = require("@sap-ux/project-access");
9
10
  const ui5_config_1 = require("@sap-ux/ui5-config");
10
11
  const fs_1 = require("fs");
@@ -307,4 +308,23 @@ function proxyErrorHandler(err, req, logger, _res, _target) {
307
308
  logger.debug((0, i18n_1.t)('error.noCodeError', { error: JSON.stringify(err, null, 2), request: req.originalUrl }));
308
309
  }
309
310
  }
311
+ /**
312
+ * Adjust UI5 bootstrap URLs to load directly from UI5 CDN.
313
+ *
314
+ * @param ui5Configs the UI5 configuration of the ui5-proxy-middleware
315
+ * @param rootProject the project root
316
+ * @param logger logger to be used when running the middleware
317
+ * @returns RequestHandler to adjust bootstraps
318
+ */
319
+ function directLoadProxy(ui5Configs, rootProject, logger) {
320
+ return async (req, res, next) => {
321
+ try {
322
+ await (0, exports.injectScripts)(req, res, next, ui5Configs, rootProject);
323
+ }
324
+ catch (error) {
325
+ logger.error(error);
326
+ next(error);
327
+ }
328
+ };
329
+ }
310
330
  //# sourceMappingURL=utils.js.map
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { ui5Proxy } from './base';
1
+ export { ui5Proxy, directLoadProxy } from './base';
2
2
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ui5Proxy = void 0;
3
+ exports.directLoadProxy = exports.ui5Proxy = void 0;
4
4
  var base_1 = require("./base");
5
5
  Object.defineProperty(exports, "ui5Proxy", { enumerable: true, get: function () { return base_1.ui5Proxy; } });
6
+ Object.defineProperty(exports, "directLoadProxy", { enumerable: true, get: function () { return base_1.directLoadProxy; } });
6
7
  //# sourceMappingURL=index.js.map
@@ -94,16 +94,7 @@ module.exports = async ({ resources, options }) => {
94
94
  }
95
95
  }
96
96
  if (directLoad) {
97
- const directLoadProxy = (async (req, res, next) => {
98
- try {
99
- await (0, base_1.injectScripts)(req, res, next, ui5Configs, resources.rootProject);
100
- }
101
- catch (error) {
102
- logger.error(error);
103
- next(error);
104
- }
105
- });
106
- routes.push({ route: '*.html', handler: directLoadProxy });
97
+ routes.push({ route: '*.html', handler: (0, base_1.directLoadProxy)(ui5Configs, resources.rootProject, logger) });
107
98
  }
108
99
  return createRequestHandler(routes);
109
100
  };
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aui5-proxy-middleware"
11
11
  },
12
- "version": "1.4.20",
12
+ "version": "1.4.21",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -37,7 +37,7 @@
37
37
  "nock": "13.4.0",
38
38
  "supertest": "6.3.3",
39
39
  "yaml": "2.2.2",
40
- "@sap-ux/project-access": "1.29.17"
40
+ "@sap-ux/project-access": "1.29.18"
41
41
  },
42
42
  "ui5": {
43
43
  "dependencies": []