dmc-local-app-router

2.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i dmc-local-app-router

Weekly Downloads

5

Version

2.0.0

License

ISC

Unpacked Size

23.4 kB

Total Files

6

Last publish

Collaborators

  • subrahmanyam_pampana