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

dmc-local-app-router

v2.0.0

Published

SAP DMC Local App Router

Downloads

44

Readme

dmc-local-app-router

local app router used to run the DMC Custom View plugins locally without deploying to DMC.

Installation

run below commond to install latest version of module. here -g represents global installation. if you want to install locally, remove -g in below command.

npm i dmc-local-app-router@latest -g

Use

  1. create local-configs.json file in the custom plugin root directory with below configs.

refer release 2.0.0 for using profile configs


{
    "port": 8085, //port number
    "localDir":"commonLib/lib", //(optional), it optional config. by default folder path maintained in mta.yaml file is used to serve the application. if specified, this property takes precedence
    "manufacturing-execution-service": "https://<host>-#service#-ms.cfapps.eu20.hana.ondemand.com", //(depricated)integration URL to make internal API calls. it is depricated, so dont use this.
    "routes":[
        //public API router
        {
            "route":"/api/:servicePath*", //DMC Public API route
            "uri":"https://api.test.<origin>.dmc.cloud.sap", // DMC Public API end point
            "auth":"papiAuth" // Authorization, its user defined name. Maintain configs for this in auths section of this JSON file
        },
        //External API router
        {
            "route":"/capService/:servicePath*", // Any external router, its user define route
            "uri":"https://<host>.cfapps.eu20.hana.ondemand.com", //Any external service end point like cap application
            "auth":"capServiceAuth" //Authorization
        },
        //Static resource like common libraries, you can remove auth field
        {
            "route":"/commonLib/:servicePath*", 
            "uri":"https://<host>cfapps.eu20.hana.ondemand.com"
        }
    ],
    "auths":{
         //Public API  oAuth Config
        "papiAuth":{
            "authUrl": "https://<host>.authentication.eu20.hana.ondemand.com/oauth/token", //Authorixation URL
            "clientId": "<clientID>",
            "clientSecret": "<client Secret>"
        },
        //External Service oAuth Config
        "capServiceAuth":{
            "authUrl": "https://<host>.authentication.eu20.hana.ondemand.com/oauth/token", //Authorixation URL
            "clientId": "<clientID>",
            "clientSecret": "<client Secret>"
        }
    }
}

2.(deprecated) In package.json file add below start script to run the app;

No need to add configs in package.json after v 2.0.0


{
    .....
    "scripts": {
      ...
      "start":"node node_modules/dmc-local-app-router/server.js", //from release 1.0.0, we can add profile config as well. using --profile parameter
      "start-g":"node $(npm root -g)/dmc-local-app-router/server.js", //only works for mac users
      ....
    },
    ...
  }

3.(deprecated from v2.0.0)run npm run start to start the application

fron release 2.0.0, we can use --profile config to configure multiple profiles like dev,qa and prod etc.

run dmclar start command in root folder to start the application from release v2.0.0

for using the profile use dmclar start --profile dev or dmclar start -pr dev for using dev profile

Relese Updates

2.0.0 Version

Below changes made as part of this patch

  1. deprecated the use of npm run start command to start the application. instead use dmclar start command directly.

you can safely remove the start scripts in your package.json file 2.added support to profile, which is useful to configure multiple environments in local-configs.json file. use --profile or -pr to pass profile as commandline argument

fallback machanisim implemented to take default configs if no profile passed

while starting the app use profile name to pick the respective configs

example:

dmclar stat --profile dev
dmclar start --profile qa
dmclar start --profile prod

sample local-configs.json file

{
    "[dev]": {
        "port": 4005,
        "manufacturing-execution-service": "<integration url for internal api calls>",
        "routes": [
            {
                "route": "/api/:servicePath*",
                "uri": "https://api.test.eu20.dmc.cloud.sap",
                "auth": "papiAuth"
            },
            {
                "route": "/capService/:servicePath*",
                "uri": "<cap service url>",
                "auth": "capServiceAuth"
            },
            {
                "route": "/dmepapidest/:servicePath*",
                "uri": "https://api.test.eu20.dmc.cloud.sap",
                "auth": "papiAuth"
            },
            {
                "route": "/commonLib/:servicePath*",
                "uri": "<static lib url>"
            }
        ],
        "auths": {
            "papiAuth": {
                "authUrl": "<auth url>/oauth/token",
                "clientId": "<client id>",
                "clientSecret": "<client secret>"
            },
            "capServiceAuth": {
                "authUrl": "<auth url>/oauth/token",
                "clientId": "<client id>",
                "clientSecret": "<client secret>"
            }
        }
    },
    "[qa]": {
        "port": 4005,
        "manufacturing-execution-service": "<integration url for internal api calls>",
        "routes": [
            {
                "route": "/api/:servicePath*",
                "uri": "https://api.test.eu20.dmc.cloud.sap",
                "auth": "papiAuth"
            },
            {
                "route": "/capService/:servicePath*",
                "uri": "<cap service url>",
                "auth": "capServiceAuth"
            },
            {
                "route": "/dmepapidest/:servicePath*",
                "uri": "https://api.test.eu20.dmc.cloud.sap",
                "auth": "papiAuth"
            },
            {
                "route": "/commonLib/:servicePath*",
                "uri": "<static lib url>"
            }
        ],
        "auths": {
            "papiAuth": {
                "authUrl": "<auth url>/oauth/token",
                "clientId": "<client id>",
                "clientSecret": "<client secret>"
            },
            "capServiceAuth": {
                "authUrl": "<auth url>/oauth/token",
                "clientId": "<client id>",
                "clientSecret": "<client secret>"
            }
        }
    },
    "[prod]": {
        "port": 4005,
        "manufacturing-execution-service": "<integration url for internal api calls>",
        "routes": [
            {
                "route": "/api/:servicePath*",
                "uri": "https://api.test.eu20.dmc.cloud.sap",
                "auth": "papiAuth"
            },
            {
                "route": "/capService/:servicePath*",
                "uri": "<cap service url>",
                "auth": "capServiceAuth"
            },
            {
                "route": "/dmepapidest/:servicePath*",
                "uri": "https://api.test.eu20.dmc.cloud.sap",
                "auth": "papiAuth"
            },
            {
                "route": "/commonLib/:servicePath*",
                "uri": "<static lib url>"
            }
        ],
        "auths": {
            "papiAuth": {
                "authUrl": "<auth url>/oauth/token",
                "clientId": "<client id>",
                "clientSecret": "<client secret>"
            },
            "capServiceAuth": {
                "authUrl": "<auth url>/oauth/token",
                "clientId": "<client id>",
                "clientSecret": "<client secret>"
            }
        }
    }
}

1.0.7 Version

Below changes made as part of this patch
1. Made 'auth' field in routes as optional field so you can add static resource routes without authorization
2. Added 'localDir' field to control while folder to be served
3. Added ReadME.md file with documentation