Socket
Book a DemoInstallSign in
Socket

@sap-ux/preview-middleware

Package Overview
Dependencies
Maintainers
3
Versions
563
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sap-ux/preview-middleware

Preview middleware

Source
npmnpm
Version
0.4.0
Version published
Weekly downloads
73K
-5.86%
Maintainers
3
Weekly downloads
 
Created
Source

@sap-ux/preview-middleware

The @sap-ux/preview-middleware is a Custom UI5 Server Middleware for previewing an application in a local Fiori launchpad . It can be used either with the ui5 serve or the fiori run commands.

Configuration Options

OptionTypeDefault ValueDescription
flpOptional configuration object for the local Fiori launchpad
flp.pathstring/test/flp.htmlThe mount point of the local Fiori launchpad.
flp.intentOptional intent to be used for the application
flp.intent.objectstringappOptional intent object
flp.intent.actionstringpreviewOptional intent action
flp.appsarray[]Optional additional local apps that are available in local Fiori launchpad
flp.libsbooleanfalseOptional flag to add a generic script fetching the paths of used libraries not available in UI5
adp.targetRequired configuration for adaptation projects defining the connected backend
adp.ignoreCertErrorsbooleanfalseOptional setting to ignore certification validation errors when working with e.g. development systems with self signed certificates
debugbooleanfalseEnables debug output

flp.apps

Array of additional application configurations:

OptionTypeDefault ValueDescription
targetstringTarget path of the additional application
localstringLocal path to the folder containing the application
intentOptional intent to be used for the application
intent.objectstring(calculated)Optional intent object, if it is not provided then it will be calculated based on the application id
intent.actionstringpreviewOptional intent action

adp.target

OptionTypeDescription
urlstring mandatory (local)Mandatory URL pointing to the backend system. *Not required if destination is provided and the proxy is running SAP Business Application Studio
destinationstring mandatory (if no url)Required if the backend system is available as destination in SAP Business Application Studio.
clientstring optionalsap-client parameter
scpboolean optionalIf set to true the proxy will execute the required OAuth routine for the ABAP environment on SAP BTP

Usage

The middleware can be used without configuration. However, since the middleware intercepts a few requests that might otherwise be handled by a different middleware, it is strongly recommended to run other file serving middlewares after the preview-middleware e.g. backend-proxy-middleware and ui5-proxy-middleware (and the corresponding middlewares in the @sap/ux-ui5-tooling). Example: ./test/fixtures/simple-app/ui5.yaml

Minimal Configuration

With no configuration provided, the app will be local FLP will be available at /test/flp.html and the log level is info.

server:
  customMiddleware:
  - name: preview-middleware
    afterMiddleware: compression

Different Path and Debugging enabled

With this configuration, the app will be local FLP will be available at /preview.html and the log level is debug.

server:
  customMiddleware:
  - name: preview-middleware
    afterMiddleware: compression
    configuration:
      flp: 
        path: /preview.html
      debug: true

Additional Applications

If you want to test cross application navigation, then you can add additional applications into the local FLP. With this configuration, an application that is locally available in ../local-folder will be available at /apps/other-app and will also be added as tile to the local FLP.

server:
  customMiddleware:
  - name: preview-middleware
    afterMiddleware: compression
    configuration:
      apps:
        - local: ../local-folder
          target: /apps/other-app

Adaptation Project

If you want to use the middleware in an adaption project, the additional adp object needs to be configured. This example would preview a local adaptation project merged with its reference application from the target system at http://sap.example and it will ignore certification validation errors.

server:
  customMiddleware:
  - name: preview-middleware
    afterMiddleware: compression
    configuration:
      adp: 
        target: 
          url: http://sap.example
        ignoreCertErrors: true

Programmatic Usage

Alternatively you can use the underlying middleware fuction programmatically, e.g. for the case when you want to incorporate the preview-middleware functionality in your own middleware.

import { FlpSandbox } from '@sap-ux/preview-middleware';
const flp = new FlpSandbox(flpConfig, rootProject, middlewareUtil, logger);
const files = await resources.rootProject.byGlob('/manifest.json');
flp.init(JSON.parse(await files[0].getString()));

return flp.router
  • flpConfig - the FLP configuration
  • rootProject - Reader to access resources of the root project
  • middlewareUtil - MiddlewareUtil of the UI5 server
  • logger - Logger instance for use in the middleware.

FAQs

Package last updated on 28 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts