@mashroom/mashroom-portal-remote-app-registry
A Mashroom Portal plugin to dynamically register Mashroom Portal Apps on a remote server
Last updated 25 days ago by jkofler .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @mashroom/mashroom-portal-remote-app-registry 
SYNC missed versions from official npm registry.

Mashroom Portal Remote App Registry

Plugin for Mashroom Server, a Integration Platform for Microfrontends.

Adds a remote app registry to Mashroom Portal. Scans periodically a list of remote servers for Portal Apps. It expects the package.json (containing a mashroom property) to be exposed at /. You can find an example remote app here: Mashroom Demo Remote Portal App.

It also comes with an Admin UI (/portal-remote-app-registry/admin) and a REST API to add and remote URL's. The Admin UI allows adding a URL temporary only for the current session.

Rewrites the resourcesRoot and rest proxy targetUri properties if necessary (when they point to the local filesystem or localhost).

Example:

{
    "name": "My App On A Remote Server",
    "defaultConfig": {
         "resourcesRoot": "./dist",
         "restProxies": {
             "bff": {
                 "targetUri": "http://localhost/app1/api"
             }
         }
     }
}

Hosted on http://my-server.com/app1 it will be converted to:

{
    "name": "My App On A Remote Server",
    "defaultConfig": {
        "resourcesRoot": "http://my-server.com/app1",
        "restProxies": {
            "bff": {
                "targetUri": "http://my-server.com/app1/api"
            }
        }
    }
}

Usage

If node_modules/@mashroom is configured as plugin path just add @mashroom/mashroom-portal-remote-app-registry as dependency.

You can override the default config in your Mashroom config file like this:

{
  "plugins": {
        "Mashroom Portal Remote App Registry": {
            "remotePortalAppUrls": "./remote-portal-apps.json",
            "checkIntervalSec": 30,
            "registrationRefreshIntervalSec": 3600
        },
        "Mashroom Portal Remote App Registry Webapp": {
            "path": "/portal-remote-app-registry",
            "showAddRemoteAppForm": true
        }
    }
}
  • remotePortalAppUrls: Location of the config file with the remote URLs, relative to the server config (Default: ./remote-portal-apps.json)
  • checkIntervalSec: The interval to check new or invalid registrations
  • registrationRefreshIntervalSec: Scan interval (Default: 3600)
  • path: Path of the Admin UI and the REST API (Default: /portal-remote-app-registry)
  • showAddRemoteAppForm: Show the Add a new Remote Portal App Endpoint form in the Admin UI

The config file contains just an array of URL's:

[
    "http://demo-remote-app.mashroom-server.com"
]

The Service can be used like this:

// @flow

import type {MashroomPortalRemoteAppEndpointService} from '@mashroom/mashroom-portal-remote-app-registry/type-definitions';

export default async (req: ExpressRequest, res: ExpressResponse) => {
    const remoteAppService: MashroomPortalRemoteAppEndpointService = req.pluginContext.services.remotePortalAppEndpoint.service;

    const remoteApps = await remoteAppService.findAll();

    // ...
}

The REST API can be used like this:

Available at /portal-remote-app-registry/api. Methods:

  • GET / : List of current URL's
  • POST / : Add a new URL. Request body:
    {
       "url": "http://my-server.com/app1",
       "sessionOnly": false
    }
    
  • DELETE /<url> : Delete given URL

Services

MashroomPortalRemoteAppEndpointService

The exposed service is accessible through pluginContext.services.remotePortalAppEndpoint.service

Interface:

export interface MashroomPortalRemoteAppEndpointService {
    /**
     * Register a new Remote App URL
     */
    registerRemoteAppUrl(url: string): Promise<void>;
    /**
     * Register a Remote App URL only for the current session (useful for testing)
     */
    synchronousRegisterRemoteAppUrlInSession(url: string, request: ExpressRequest): Promise<void>;
    /**
     * Unregister a Remote App
     */
    unregisterRemoteAppUrl(url: string): Promise<void>;
    /**
     * Find Remote App by URL
     */
    findRemotePortalAppByUrl(url: string): Promise<?RemotePortalAppEndpoint>;
    /**
     * Return all known Remote App endpoints
     */
    findAll(): Promise<Array<RemotePortalAppEndpoint>>;
    /**
     * Update an existing Remote App endpoint
     */
    updateRemotePortalAppEndpoint(remotePortalAppEndpoint: RemotePortalAppEndpoint): Promise<void>;
    /**
     * Refresh (fetch new metadata) from given endpoint
     */
    refreshEndpointRegistration(remotePortalAppEndpoint: RemotePortalAppEndpoint): Promise<void>;
}

Current Tags

  • 1.4.5                                ...           latest (25 days ago)

23 Versions

  • 1.4.5                                ...           25 days ago
  • 1.4.4                                ...           a month ago
  • 1.4.3                                ...           a month ago
  • 1.4.2                                ...           a month ago
  • 1.4.1                                ...           a month ago
  • 1.4.0                                ...           2 months ago
  • 1.3.2                                ...           3 months ago
  • 1.3.1                                ...           4 months ago
  • 1.3.0                                ...           4 months ago
  • 1.2.3                                ...           5 months ago
  • 1.2.2                                ...           6 months ago
  • 1.2.1                                ...           6 months ago
  • 1.2.0                                ...           6 months ago
  • 1.1.4                                ...           7 months ago
  • 1.1.3                                ...           7 months ago
  • 1.1.2                                ...           8 months ago
  • 1.1.1                                ...           8 months ago
  • 1.1.0                                ...           8 months ago
  • 1.0.94                                ...           9 months ago
  • 1.0.93                                ...           9 months ago
  • 1.0.92                                ...           10 months ago
  • 1.0.91                                ...           10 months ago
  • 1.0.90                                ...           10 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 39
Last Day 0
Last Week 0
Last Month 53
Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |