Custom UI5 server middleware for projects using UI5 Tooling
- Provides proxy capabilities and support for
neo-app.json
routes - Works with destinations from destination files, as WebIDE does
- Supports serving resources from local system or remote CDN (like the SAPUI5 SDK or an ABAP application server)
npm i --save-dev ui5-middleware-destination
Create a directory to hold the destination files needed for your project -- preferably, out of your project's root so that the same config can be used for multiple projects. This also helps keeping your credentials from being committed.
This middleware will look in that directory for one (or many) json file(s) with a specific structure (check the example json).
As an alternative, the middleware will also look for destination files in the created directory. The structure of these files is the same as the one used in WebIDE destination files (also check the example template).
For the time being, the only properties required in a destination configuration are Name
, URL
, User
, Password
and WebIDEUsage
.
NOTE: Storing passwords in plain text format is a potential security risk. Please comply with your organization's policy.
{
"Name": "sapui5", // Name is used as an identifier
"Description": "SAPUI5 Resources",
"URL": "C:\\Dev\\workspace\\sapui5\\sdk", // Can be used to specify cdn URL e.g. https://sapui5.hana.ondemand.com/
"preferLocal": false // Flag to determine whether the resources files will be served from local system or cdn remote server
}
"devDependencies": {
// ...
"ui5-middleware-destination": "*"
// ...
},
"ui5": {
"dependencies": [
// ...
"ui5-middleware-destination",
// ...
]
}
As the devDependencies are not recognized by the UI5 tooling, they need to be listed in the
ui5.dependencies
array. In addition, once using theui5.dependencies
array you need to list all UI5 tooling relevant dependencies.
server:
customMiddleware:
- name: ui5-middleware-destination
afterMiddleware: cors
configuration:
destinationsPath: '../path/to/destination/files'
server:
customMiddleware:
- name: ui5-middleware-destination
afterMiddleware: cors
configuration:
debug: true
destinationsPath: '../path/to/destination/files'
resources:
preferLocal: false
path: 'https://path/to/CDN/resources'
server:
customMiddleware:
- name: ui5-middleware-destination
afterMiddleware: cors
configuration:
debug: true
destinationsPath: '../path/to/destination/files'
resources:
preferLocal: false
path: 'https://<host>:<port>/path/to/ABAP/AS/resources'
strictSSL: false
server:
customMiddleware:
- name: ui5-middleware-destination
afterMiddleware: cors
configuration:
destinationsPath: '../path/to/destination/files'
resources:
preferLocal: true
path: '../local/path/to/resources'
ATTENTION: No options are mandatory, EXCEPT for destinationsPath
. This option must be provided either in the ui5.yml
file or as an environment variable (as in the description below).
Note that relative paths declared in these options are resolved against the project's root.
-
debug
(boolean, default:false
)
Enables the logging of each request and where it is served from. -
destinationsPath
(string)
Absolute or relative path to the destination files.
If a relative path is provided, it is resolved against the project's root folder.
If you do not provide this option in theui5.yml
file, you must set theUI5_MIDDLEWARE_DESTINATIONS_PATH
environment variable. -
strictSSL
(boolean, default:true
)
When set to false, the proxy does not validate SSL certificates of the resource server.
This covers the use case of, for example, serving routes from a corporate ABAP AS with a self-signed certificate. -
resources
(object)
Options regarding SAPUI5 resources:-
path
(string)
IfpreferLocal
istrue
, then this is the local absolute or relative path to SAPUI5 resources.
WhenpreferLocal
isfalse
, you can provide a CDN URL for the SAPUI5 resources. or https://sapui5.hana.ondemand.com will be used as CDN source
This option can be provided either in theui5.yml
file or through theUI5_MIDDLEWARE_RESOURCES_PATH
environment variable. -
preferLocal
(boolean, default:false
)
Whentrue
, middleware redirects all the ui5 resources requests to local filesystem. This option can be provided throughUI5_MIDDLEWARE_RESOURCES_LOCAL
environment variable. Possible values in environment variable can be0
or1
.
-
- Integrates node-http-proxy to proxy requests to remote server using the destination files.
- Integrates serve-static to serve static resources from a local path.
Currently only BasicAuthentication is supported.
Pull Request are welcome. However, if change is complex or huge, Please create an issue and have a discussion on the approach before developing something.
Project is distributed under MIT License