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

predix-apphub-config-service

v1.0.1

Published

A simple nav service implementation as required by the AppHub

Downloads

3

Readme

apphub-config-service

Build Status

A simple implementation of a nav service as required by the UI AppHub.

Usage

After cloning this repo, install runtime dependencies:

% npm install

To start:

% node app.js

Provision Tenant

In CF:

cf cs predix-apphub Beta js-apphub-beta \
--config '{"uaa":{"uaaUri":"https://js-uaa-prod.predix-uaa.run.aws-usw02-pr.ice.predix.io","clientID":"apphub","clientSecret":"apphub"},"appConfigURL":"","routeInfo":{"hostName”:”js-apphub-beta","context":"","shared":false},"applicationChrome":true, "customHeader": {}}'

Metrics

A very basic, but correct and useful, prometheus.yml can look like this.

scrape_configs:  
- job_name: PrometheusApp
  scrape_interval: 5s
  scrape_timeout: 5s
  metrics_path: /ijdc72jg2ugg2dikkkl236f2rhma6qaz/metrics
  scheme: https
  static_configs:
  - targets:
    - integration.cloud.tibcoapps.com
    labels:
      app: PrometheusApp
      sandbox: MyDefaultSandbox

Details

This service exposes two routes: / and /nav/<app id>. The root route returns the entire config object for a hub instance, for example: Your Hub configuration service should return some JSON response such as this below: Start with your Main AppHub name, it appears at the top left corner of the view port. the apps property holds information regarding to all the micro apps that you intend to bundle with your main App.

For example:

EX1

Calling /, this service return this JSON.

  • name - The name of your application, it appears at the top of the navigation bar
  • user - The user information, this config service needs to provide such information to ui-app-hub. At minimum, user name, however, user.picture (optional) is where the user avatar image url is. You can also provide 'firstName' and 'lastName', if this is specified, it takes a precedence over 'name'. You are free to add whatever additional key/value pairs you like.
  • apps[0].id - a unique identifier for this micro app.
  • apps[0].host - the domain url of this micro app.
  • apps[0].path - the base url path of this micro app, it will be added to the host so when users click the navigation links on the left navigation side bar, it will take them to the micro app. If a fully qualified url is specified for e.g. "https://www.predix.io/resources" then it will open the url in the a new window.
  • apps[0].template - the main html page for that path. apps[0].navService is where app-hub will pull/query the navigation information from your micro app so it can construct the relative url links for your app.
  • apps[0].default - if set to true, it means you want app-hub to load this micro app as soon as user log in.
  • apps[0].location - where links of your micro app should be placed in the navigation side bar. We have three locations, "main", "profile", and "settings. "main" location is for the main navigation section, "profile" location is for user specific functionality, "settings" location is for app/system related functionality.
{
  "name":"AppHub Demo",
  "user": { "name": "hubpocuser", "firstName": "First", "lastName": "Last", "picture": "https://user.ge.com/avatar"},
  "apps":[
    {
      "id":"dashboard",
      "location": "main",
      "host":"http://dashboard.com",
      "path":"/dash",
      "template":"/content.html",
      "navService":"/nav",
      "default":"true"
    },
    {
      "id":"analytics",
      "location": "main",
      "host":"http://analytics.com",
      "path":"/analytics",
      "template":"/content.html",
      "navService":"/nav"
    },

    {
      id:'user',
      location: 'profile',
      host:  'http://<your-use-profile-domain>',
      path:'/user',
      template:'/index.html',
      navService:'/nav'
    },
    {
      id:'settings',
      location:'settings',
      host: 'http://<your-settings-domain>',
      path:"/settings",
      template:"/index.html",
      navService:'/nav/settings'
    }
  ]
}

Calling the /nav/<app id> route returns the navigation details for a single micro app:

{
"id":"analytics",
  "path":"/analytics",
  "items":[
    {
      "label":"Analytics",
      "icon":"fa-gauge",
      "path":"/analytics/#/",
      "items":[
        {
          "label":"New",
          "path":"/analytics/#/create"
        }
      ]
    }
  ]
}

Note: Each navService specified under above apps e.g. /nav/ /nav/settings route returns the navigation details for a single micro app. ui-app-hub uses will make call to these navServices when server is started. It is vital to provide these links for routing of micro app should it offer many routes and url path for user to navigate.

EX2

This example is mainly the same as the above except that some of the micro apps whose navigation item object are defined already. As a result, ui-app-hub will not make request to fetch the navigation item object for that particular micro app. For instance:

  • apps[0].items offers links for sub sections of your micro app. These sub items follow nearly the same structure of the main micro app properties, excluding "location".
  • you can mix and match both approach.
{
  "name":"AppHub Demo",
  "user": { "name": "hubpocuser", "firstName": "First", "lastName": "Last", "picture": "https://user.ge.com/avatar"},
  "apps":[
    {
      "id":"dashboard",
      "location": "main",
      "host":"http://dashboard.com",
      "path":"/dash",
      "template":"/content.html",
      "default":"true",
      "items":[
        {
          "label":"Dashboard",
          "icon":"fa-dashboard",
          "path":"/dash/#/",
          "items":[
            {
              "label":"Notifications",
              "path":"/dash/#/notifications",
              "badge":{
                "status":"info",
                "count":1
              }
            }
          ]
        }
      ]
    },
    {
      "id":"analytics",
      "location": "main",
      "host":"http://analytics.com",
      "path":"/analytics",
      "template":"/content.html",
      "items":[
        {
          "label":"Analytics",
          "icon":"fa-gauge",
          "path":"/analytics/#/",
          "items":[
            {
              "label":"New",
              "path":"/analytics/#/create"
            }
          ]
        }
      ]
    },

    {
      id:'user',
      location: 'profile',
      host:  'http://<your-use-profile-domain>',
      path:'/user',
      template:'/index.html',
      navService:'/nav'

    },
    {
      id:'settings',
      location:'settings',
      host: 'http://<your-settings-domain>',
      path:"/settings",
      template:"/index.html",
      "items":[
        {
          "label":"Settings",
          "icon":"fa-gauge",
          "path":"/settings/#/"
        },
                {
          "label":"Help",
          "icon":"fa-gauge",
          "path":"https://www.predix.io/resources"
        }
      ]

    }
  ]
}

Authorization

The UI Config Service should properly authorize against any bearer token passed in the request. If a user doesn't have access to a microapp, that microapp shouldn't appear in the "apps" array.

##Other Questions

Do you still have questions? If so, post them on http://stackoverflow.apps.ge.com/ tagged with apphub or app-hub. Our team checks there every so often.

Performance

Baseline Test

1000 POST requests 1000 GET requests