@sap-ux/ui5-proxy-middleware 1.1.35 → 1.2.1
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/README.md +14 -13
- package/dist/base/utils.js +1 -1
- package/dist/ui5/middleware.js +6 -8
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ The `@sap-ux/ui5-proxy-middleware` is a [Custom UI5 Server Middleware](https://s
|
|
|
5
5
|
## Configuration Options
|
|
6
6
|
| Option | Default Value | Description |
|
|
7
7
|
| ------------ | ------------- | ----------- |
|
|
8
|
-
| `ui5` |
|
|
8
|
+
| `ui5` | `object` | List of mount paths and target urls that should be handled by the proxy. If not provided then `/resources` and `/test-resources` are proxied to `https://ui5.sap.com` |
|
|
9
9
|
| `version` | `undefined` | The UI5 version. If this property is not defined, then the `minUI5Version` from the `manifest.json` will be used |
|
|
10
10
|
| `secure` | true | Defines if SSL certs should be verified |
|
|
11
11
|
| `debug` | false | Enables debug output |
|
|
@@ -13,7 +13,19 @@ The `@sap-ux/ui5-proxy-middleware` is a [Custom UI5 Server Middleware](https://s
|
|
|
13
13
|
| `directLoad` | false | Defines whether the UI5 sources should be loaded directly from UI5 CDN |
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
16
|
-
In order to use the middleware this is the minimal configuration that you need to provide in the `ui5.yaml` of your application.
|
|
16
|
+
In order to use the middleware this is the minimal configuration that you need to provide in the `ui5.yaml` of your application. All requests to `/resources` and `/test-resources` will be proxied to the latest UI5 version at https://ui5.sap.com.
|
|
17
|
+
|
|
18
|
+
```yaml
|
|
19
|
+
server:
|
|
20
|
+
customMiddleware:
|
|
21
|
+
- name: ui5-proxy-middleware
|
|
22
|
+
afterMiddleware: compression
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Examples
|
|
26
|
+
|
|
27
|
+
### Defining url and path
|
|
28
|
+
If you want to explicitly define paths that should be proxied to a specific server, the following configuration is required.
|
|
17
29
|
|
|
18
30
|
```Yaml
|
|
19
31
|
server:
|
|
@@ -44,17 +56,6 @@ server:
|
|
|
44
56
|
```
|
|
45
57
|
**NOTE: You can't mix both syntaxes!**
|
|
46
58
|
|
|
47
|
-
Finally don't forget to add the following in your `package.json`.
|
|
48
|
-
|
|
49
|
-
```JSON
|
|
50
|
-
"ui5": {
|
|
51
|
-
"dependencies": [
|
|
52
|
-
"@sap-ux/ui5-proxy-middleware"
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Examples
|
|
58
59
|
### Loading a specific UI5 version
|
|
59
60
|
To load a specific a UI5 version in your application you can use the `version` parameter, e.g.
|
|
60
61
|
|
package/dist/base/utils.js
CHANGED
|
@@ -38,7 +38,7 @@ exports.proxyResponseHandler = proxyResponseHandler;
|
|
|
38
38
|
* @param logger - Logger for loging the requests
|
|
39
39
|
*/
|
|
40
40
|
const proxyRequestHandler = (proxyReq, res, etag, logger) => {
|
|
41
|
-
logger.
|
|
41
|
+
logger.debug(proxyReq.path);
|
|
42
42
|
if (proxyReq.getHeader('if-none-match') === etag) {
|
|
43
43
|
res.statusCode = 304;
|
|
44
44
|
res.end();
|
package/dist/ui5/middleware.js
CHANGED
|
@@ -64,16 +64,14 @@ function loadManifest(rootProject) {
|
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
module.exports = ({ resources, options }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
-
var _a;
|
|
68
67
|
const logger = new logger_1.ToolsLogger({
|
|
69
68
|
transports: [new logger_1.UI5ToolingTransport({ moduleName: 'ui5-proxy-middleware' })]
|
|
70
69
|
});
|
|
71
|
-
if (!((_a = options.configuration) === null || _a === void 0 ? void 0 : _a.ui5)) {
|
|
72
|
-
logger.error('Configuration missing, no proxy created.');
|
|
73
|
-
return (_req, _res, next) => next();
|
|
74
|
-
}
|
|
75
70
|
dotenv_1.default.config();
|
|
76
|
-
const config =
|
|
71
|
+
const config = Object.assign({ ui5: {
|
|
72
|
+
path: ['/resources', '/test-resources'],
|
|
73
|
+
url: 'https://ui5.sap.com'
|
|
74
|
+
} }, options.configuration);
|
|
77
75
|
let ui5Version = '';
|
|
78
76
|
try {
|
|
79
77
|
const manifest = yield loadManifest(resources.rootProject);
|
|
@@ -107,7 +105,7 @@ module.exports = ({ resources, options }) => __awaiter(void 0, void 0, void 0, f
|
|
|
107
105
|
}
|
|
108
106
|
}
|
|
109
107
|
if (directLoad) {
|
|
110
|
-
const directLoadProxy = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
+
const directLoadProxy = ((req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
111
109
|
try {
|
|
112
110
|
yield (0, base_1.injectScripts)(req, res, next, ui5Configs);
|
|
113
111
|
}
|
|
@@ -115,7 +113,7 @@ module.exports = ({ resources, options }) => __awaiter(void 0, void 0, void 0, f
|
|
|
115
113
|
logger.error(error);
|
|
116
114
|
next(error);
|
|
117
115
|
}
|
|
118
|
-
});
|
|
116
|
+
}));
|
|
119
117
|
base_1.HTML_MOUNT_PATHS.forEach((path) => {
|
|
120
118
|
routes.push({ route: path, handler: directLoadProxy });
|
|
121
119
|
});
|
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.1
|
|
12
|
+
"version": "1.2.1",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"i18next": "20.3.2",
|
|
28
28
|
"proxy-from-env": "1.1.0",
|
|
29
29
|
"@sap-ux/logger": "0.3.7",
|
|
30
|
-
"@sap-ux/ui5-config": "0.19.
|
|
30
|
+
"@sap-ux/ui5-config": "0.19.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/express": "4.17.17",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"nock": "13.2.4",
|
|
38
38
|
"supertest": "6.3.3",
|
|
39
39
|
"yaml": "2.2.2",
|
|
40
|
-
"@sap-ux/project-access": "1.13.
|
|
40
|
+
"@sap-ux/project-access": "1.13.4"
|
|
41
41
|
},
|
|
42
42
|
"ui5": {
|
|
43
43
|
"dependencies": []
|