npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ui5-middleware-route

v1.0.4

Published

custom ui5 middleware extension for routing http and static requests

Downloads

70

Readme

JavaScript Style Guide

ui5-middleware-route

Custom UI5 middleware extension for routing http requests using request and static requests using serve-static with http basic authentication support.

For routing requests from a local development enviroment and/or serving ui5/odata/library resources from a remote host/static sources on your system.

Prerequisites

Make sure your project is using the latest UI5 Tooling.

Getting started

Install

Custom middleware

Add the custom middleware as a devDependency to your project.

With yarn:

yarn add -D ui5-middleware-route

Or npm:

npm i -D ui5-middleware-route

Additionally the custom task needs to be manually defined as a ui5 dependency in your project's package.json:

{
  "ui5": {
    "dependencies": [
      "ui5-middleware-route"
    ]
  }
}

Configure

If baseUrl is specified, the routing will proxy to a remote host. If not specified, it will route to a static source.

Custom middleware

Multiple sample configurations below. Register the custom task in your project's ui5.yaml:

server:
  customMiddleware:
    # Remote host routing for ui5 resources
    - name: ui5-middleware-route
      mountPath: /resources
      beforeMiddleware: compression
      configuration:
        baseUrl: https://ui5.sap.com
        path: /resources
    # Static source routing for ui5 resources
    - name: ui5-middleware-route
      mountPath: /resources
      beforeMiddleware: compression
      configuration:
        path: Y:/Development/sapui5/rt/resources         
    # Remote host routing for ui5 test resources
    - name: ui5-middleware-route
      mountPath: /test-resources
      beforeMiddleware: compression
      configuration:
        baseUrl: http://localhost:8080
        path: /test-resources
    # Remote host routing with http basic authentication. (If migrating from Web IDE, you can refer to the paths in neo-app.json) 
    - name: ui5-middleware-route
      mountPath: /sap/opu/odata/
      beforeMiddleware: compression
      configuration:
        debug: true
        baseUrl: http://companytesturl:8001
        path: /sap/opu/odata/
        secure: false
        auth:
          user: userTest
          pass: passTest       
    # Remote host routing for custom SAPUI5 Libraries deployed in Gateway       
    - name: ui5-middleware-route
      mountPath: /sap/bc/ui5_ui5
      beforeMiddleware: compression
      configuration:
        debug: true
        baseUrl: http://companytesturl:8001
        path: /sap/bc/ui5_ui5
        secure: false
        auth:
          user: userTest
          pass: passTest      
    # Static source routing for custom Local UI5 Library resources  
    - name: ui5-middleware-route
      mountPath: /resources/companytest
      beforeMiddleware: compression    
      configuration:
        path: /Users/Me/Desktop/Development/companytest-sapui5-library/src/companytest                            

Additional configuration

Environment file is supported. Define an .env file with your username and password:

UI5_ROUTE_USER=<username>
UI5_ROUTE_PASSWORD=<password>

If this is defined, you can omit the auth object above in your ui5.yaml

You can also define the UI5_ROUTE_BASEURL variable for your baseUrl config:

UI5_ROUTE_BASEURL=http://companytesturl:8001
    - name: ui5-middleware-route
      mountPath: /sap/opu/odata/
      beforeMiddleware: compression
      configuration:
        debug: true
        baseUrl: UI5_ROUTE_BASEURL
        path: /sap/opu/odata/
        secure: false

Options

The custom middleware accepts the following configuration options

| name | type | Description | mandatory | default | examples | |:------------:|:-------:|:-----------------------------------------:|:---------:|:-------:|:-----------------------------------------------------:| | debug | boolean | enable/disable debug logs | no | false | true, false | | baseUrl | string | baseUrl for proxying requests | yes | - | https://services.odata.org, http://localhost:8080 | | path | string | path for routing requests | no | / | /resources, /V2/Northwind/Northwind.svc | | secure | boolean | reject self-signed certificates | no | true | true, false | | auth | object | credentials for http basic authentication | no | - | | | auth.user | string | user for http basic authentication | no | - | userTest | | auth.pass | string | password for http basic authentication | no | - | userTest |