Custom Server middleware to provide proxy capabilities and support neo-app.json
npm install ui5-middleware-destinationneo-app.json routes
bash
npm i --save-dev ui5-middleware-destination
`
Pre-requisites
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.
Options for SAPUI5 config in destinations file
`jsonc
{
"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
}
`
Usage
$3
`jsonc
"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 the ui5.dependencies array you need to list all UI5 tooling relevant dependencies.
$3
#### Simplest usage:
`yaml
server:
customMiddleware:
- name: ui5-middleware-destination
afterMiddleware: cors
configuration:
destinationsPath: '../path/to/destination/files'
`
#### Example config serving from CDN:
`yaml
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'
`
#### Example config serving from an ABAP AS with self-signed certificate:
`yaml
server:
customMiddleware:
- name: ui5-middleware-destination
afterMiddleware: cors
configuration:
debug: true
destinationsPath: '../path/to/destination/files'
resources:
preferLocal: false
path: 'https://:/path/to/ABAP/AS/resources'
strictSSL: false
`
#### Example config serving from local resources:
`yaml
server:
customMiddleware:
- name: ui5-middleware-destination
afterMiddleware: cors
configuration:
destinationsPath: '../path/to/destination/files'
resources:
preferLocal: true
path: '../local/path/to/resources'
`
Configuration options
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 the ui5.yml file, you must set the UI5_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)*
If preferLocal is true, then this is the local absolute or relative path to SAPUI5 resources.
When preferLocal is false, 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 the ui5.yml file or through the UI5_MIDDLEWARE_RESOURCES_PATH environment variable.
preferLocal (boolean, default: false)*
When true, middleware redirects all the ui5 resources requests to local filesystem.
This option can be provided through UI5_MIDDLEWARE_RESOURCES_LOCAL environment variable. Possible values in environment variable can be 0 or 1`.